runtothefather / doctrine-psalm-plugin
Repository resolver to show psalm how to resolve getRepository method
Installs: 6 218
Dependents: 0
Suggesters: 0
Security: 0
Stars: 7
Watchers: 3
Forks: 2
Open Issues: 0
Type:psalm-plugin
Requires
- doctrine/orm: ^2.6
- symfony/doctrine-bridge: ^4.3
- vimeo/psalm: ^3.8
Requires (Dev)
- phpunit/phpunit: ^8.5
README
By default psalm doesn't recognize return type for cases like this
$object->getRepository(Entity::class)
where $object can be instance of
Doctrine\Common\Persistence\ObjectManager
Symfony\Bridge\Doctrine\RegistryInterface
Doctrine\Common\Persistence\AbstractManagerRegistry
Doctrine\Common\Persistence\ManagerRegistry
repository class from @ORM\Entity(repositoryClass="Doctrine\Common\Persistence\ObjectRepository")
will be returned
Usage
Add into your psalm.xml file into <plugins>
section line
<plugin filename="vendor/runtothefather/doctrine-psalm-plugin/src/ReturnTypeProvider/GetRepositoryReturnTypeProvider.php"></plugin>