File tree Expand file tree Collapse file tree 1 file changed +12
-0
lines changed Expand file tree Collapse file tree 1 file changed +12
-0
lines changed Original file line number Diff line number Diff line change 22
33namespace PHPStan \Type \Doctrine ;
44
5+ use Doctrine \ORM \Mapping \Entity ;
56use Doctrine \Persistence \ObjectManager ;
67use PHPStan \Reflection \ReflectionProvider ;
78use function is_file ;
@@ -97,6 +98,17 @@ public function getResolvedRepositoryClass(): string
9798
9899 public function getRepositoryClass (string $ className ): string
99100 {
101+ if (PHP_MAJOR_VERSION >= 8 && $ this ->reflectionProvider ->hasClass ($ className )) {
102+ $ classReflection = $ this ->reflectionProvider ->getClass ($ className )->getNativeReflection ();
103+ $ attribute = $ classReflection ->getAttributes (Entity::class)[0 ] ?? null ;
104+ if ($ attribute !== null ) {
105+ $ attributeInstance = $ attribute ->newInstance ();
106+ if ($ attributeInstance ->repositoryClass !== null ) {
107+ return $ attributeInstance ->repositoryClass ;
108+ }
109+ }
110+ }
111+
100112 $ objectManager = $ this ->getObjectManager ();
101113 if ($ objectManager === null ) {
102114 return $ this ->getResolvedRepositoryClass ();
You can’t perform that action at this time.
0 commit comments