EntityRepository::__construct() expects Doctrine\ORM\EntityManager instead of actual required EntityManagerInterface #6126

Open
opened 2026-01-22 15:27:12 +01:00 by admin · 0 comments
Owner

Originally created by @koftikes on GitHub (Dec 12, 2018).

Originally assigned to: @koftikes on GitHub.

Bug Report

When I do phpstan check of my code.

Q A
BC Break yes
Version 2.6.x

Summary

Parameter #1 $em of method Doctrine\ORM\EntityRepository::__construct() expects Doctrine\ORM\EntityManager, Doctrine\ORM\EntityManagerInterface given.

How to reproduce

class RequestMasterRepository extends EntityRepository implements ServiceEntityRepositoryInterface
{
    /**
     * CompanyConfigRepository constructor.
     *
     * @param EntityManagerInterface $manager
     */
    public function __construct(EntityManagerInterface $manager)
    {
        parent::__construct($manager, $manager->getClassMetadata(RequestMaster::class));
    }
....

And run phpstam level 7 to this file.

vendor/bin/phpstan analyse -c phpstan.neon -l max src/AppBundle/Repository/
Originally created by @koftikes on GitHub (Dec 12, 2018). Originally assigned to: @koftikes on GitHub. ### Bug Report When I do phpstan check of my code. | Q | A |------------ | ------ | BC Break | yes | Version | 2.6.x #### Summary ``` Parameter #1 $em of method Doctrine\ORM\EntityRepository::__construct() expects Doctrine\ORM\EntityManager, Doctrine\ORM\EntityManagerInterface given. ``` #### How to reproduce ``` class RequestMasterRepository extends EntityRepository implements ServiceEntityRepositoryInterface { /** * CompanyConfigRepository constructor. * * @param EntityManagerInterface $manager */ public function __construct(EntityManagerInterface $manager) { parent::__construct($manager, $manager->getClassMetadata(RequestMaster::class)); } .... ``` And run phpstam level 7 to this file. ``` vendor/bin/phpstan analyse -c phpstan.neon -l max src/AppBundle/Repository/ ```
admin added the Documentation label 2026-01-22 15:27:12 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#6126