Open
Description
see: this discussion and @ondrejmirtes's response.
CODE
/**
* @template TypeEntity of AbstractThisEntity
* @extends EntityRepository<TypeEntity>
*/
abstract class AbstractThisRepository extends EntityRepository
{
/** @return TypeEntity[] */
public function findAllActive(): array
{
return $this->getEntityManager()->createQueryBuilder()
->select('entity')
->from($this->getEntityClass(), 'entity')
->where('entity.active = 1')
->getQuery()
->getResult();
}
/** @return class-string<TypeEntity> */
abstract protected function getEntityClass(): string;
}
ERROR:
Method App\Repository\AbstractThisRepository::findAllActive() should return array<TypeEntity of App\Entity\AbstractThisEntity> but returns list<App\Entity\AbstractThisEntity>.
🪪 return.type
💡 Type App\Entity\AbstractThisEntity is not always the same as TypeEntity. It breaks the
contract for some argument types, typically subtypes.
Metadata
Metadata
Assignees
Labels
No labels
Activity
arderyp commentedon May 6, 2025
@ondrejmirtes is this something you still think is fixable?