Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

phpstan errors after upgrading to 2.6.3 and doctrine/orm 2.12.2 #1521

Closed
usu opened this issue May 8, 2022 · 3 comments
Closed

phpstan errors after upgrading to 2.6.3 and doctrine/orm 2.12.2 #1521

usu opened this issue May 8, 2022 · 3 comments

Comments

@usu
Copy link

usu commented May 8, 2022

After upgrading to DoctrineBundle 2.6.3 and doctrine/orm 2.12.2 I'm getting the following phpstan errors:

Parameter $repositoryClass of attribute class Doctrine\ORM\Mapping\Entity constructor expects class-string<Doctrine\ORM\EntityRepository<T of object>>|null, 'App\\Repository\\MyEntityRepository' given.

Is this an issue in DoctrineBundle? Or in doctrine/orm? Or an issue on my side?
I'm using phpstan 1.6.7 on level 5.

namespace App\Entity;

use App\Repository\MyEntityRepository;

#[ORM\Entity(repositoryClass: MyEntityRepository::class)]
class MyEntity {
}
namespace App\Repository;

use App\Entity\MyEntity;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\Persistence\ManagerRegistry;

class MyEntityRepository extends ServiceEntityRepository {
    public function __construct(ManagerRegistry $registry) {
        parent::__construct($registry, MyEntity::class);
    }
}
@nicolas-grekas
Copy link
Member

That issue is for maker-bundle, which should generate the annotation.
Not a bug here since that's "just" about a missing annotation.
@extends ServiceEntityRepository<MyEntity> I guess

@nicolas-grekas
Copy link
Member

nicolas-grekas commented May 8, 2022

In theory, phpstan could be able to infer the type of the template by looking at the second argument of ServiceEntityRepository's call to parent::__construct(). Dunno how hard this would be to implement. That might be another issue for phpstan/psalm.

@usu
Copy link
Author

usu commented May 11, 2022

Thanks for the quick feedback. I believe this was fixed in the meantime in phpstan (phpstan/phpstan#7171) and shipped with phpstan 1.6.8 (https://github.com/phpstan/phpstan/releases/1.6.8)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants