phpstan并未将符号实体解释为通用

发布于 2025-01-27 09:14:50 字数 1018 浏览 5 评论 0原文

我很难理解这个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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

我最亲爱的 2025-02-03 09:14:50

这是Phpstan中的一个错误。

解决方案:将phpstan升级为1.6.8。

This was a bug in phpstan.

Solution: Upgrade phpstan to 1.6.8.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文