EntityRepository.stub missing Selectable interface

未关闭 适合新手
#785 0 条评论 1 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

@lyn1dev 已经在做这个了。

开始于 2026年11月24日。

  • #823 来自 @lyn1dev —— 未关闭

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
74/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
冷清
技术栈
php
领域
devtools

调研方向

定位 Doctrine EntityRepository 存根,并将其模板注解和已实现的接口与 issue 中所示的声明进行比较。使用 PHPStan 重现 MyRepository 示例,然后验证通用接口冲突错误已消失,同时 repository 类型仍然正确。

由索引模型根据 Issue 内容生成。

描述

It seems that compared to doctrine EntityRepository, the stub is missing generics and implementation of Selectable interface.

What i mean is that stub is declared:

/**
 * @template T of object
 * @implements ObjectRepository<T>
 */
class EntityRepository implements ObjectRepository
{
// ...
}

instead of:

 /**
 * @template T of object
 * @template-implements Selectable<int,T>
 * @template-implements ObjectRepository<T>
 */
class EntityRepository implements ObjectRepository, Selectable
{
// ...
}

This causes problems when I'm trying to make interface for mine repository that would cover all the methods:

/**
 * @extends EntityRepository<MyEntity>
 */
class MyRepository extends EntityRepository implements MyRepositoryInterface
{
// ...
}
/**
 * @extends ObjectRepository<MyEntity>
 * @extends Selectable<int, MyEntity>
 */
interface MyRepositoryInterface extends ObjectRepository, Selectable
{
// ...
}

This works fine without phpstan/phpstan-doctrine but fails due to stub with:

 ------ ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 
  Line   VaultRepository.php                                                                                                                                                                                 
 ------ ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 
  13     Class Doctrine\ORM\EntityRepository specifies template type T of interface Doctrine\Common\Collections\Selectable as mixed but it's already specified as Entity\MyEntity.  
         🪪  generics.interfaceConflict                                                                                                                                                                      
  13     Class Doctrine\ORM\EntityRepository specifies template type TKey of interface Doctrine\Common\Collections\Selectable as mixed but it's already specified as int.                                    
         🪪  generics.interfaceConflict                                                                                                                                                                      
 ------ ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 
主要语言
PHP
星标
683
派生
129
平均合并
13 小时 6 分钟
30 天内合并 PR
14

环境准备

这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

phpstan/phpstan-doctrine 的其他 Issue

查看 phpstan/phpstan-doctrine 的全部 Issue

相似的 Issue

更多 PHP Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。