phpstan并未将符号实体解释为通用
我很难理解这个phpstan错误。 PHPSTAN说我需要提供对象的实体重点的类字符串。我正在提供“ Schedule”类的ServiceentityRepository(扩展了EntityRepository)的类字符串。
错误
参数$ repositorityClass属性类教义\ orm \ mapping \ Entity构造器期望 class-string< doctrine \ orm \ entityRepository< t obogge>> | null,'app \ copository \ scheduleerepository'给定。
代码
是有问题的代码:
namespace App\Entity\Schedule;
use App\Repository\ScheduleRepository;
#[ORM\Entity(repositoryClass: ScheduleRepository::class)]
class Schedule implements JsonSerializable
{
// ...
引用的存储库类:(
namespace App\Repository;
use App\Entity\Schedule\Schedule;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
/*
* @extends ServiceEntityRepository<Schedule>
*/
class ScheduleRepository extends ServiceEntityRepository
{
// ...
注意:serviceentityrepository扩展了EntityRepository。)
I'm having trouble making sense of this PHPStan error. PHPStan is saying I need to provide the class string of an EntityRepository of an object. I am providing the class string of a ServiceEntityRepository (which extends EntityRepository) of class "Schedule".
Error
Parameter $repositoryClass of attribute class Doctrine\ORM\Mapping\Entity constructor expects
class-string<Doctrine\ORM\EntityRepository<T of object>>|null, 'App\Repository\ScheduleRepository' given.
Code
Here is the offending code:
namespace App\Entity\Schedule;
use App\Repository\ScheduleRepository;
#[ORM\Entity(repositoryClass: ScheduleRepository::class)]
class Schedule implements JsonSerializable
{
// ...
And the repository class referenced:
namespace App\Repository;
use App\Entity\Schedule\Schedule;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
/*
* @extends ServiceEntityRepository<Schedule>
*/
class ScheduleRepository extends ServiceEntityRepository
{
// ...
(Note: ServiceEntityRepository extends EntityRepository.)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是Phpstan中的一个错误。
解决方案:将phpstan升级为1.6.8。
This was a bug in phpstan.
Solution: Upgrade phpstan to 1.6.8.