File tree Expand file tree Collapse file tree 2 files changed +12
-7
lines changed Expand file tree Collapse file tree 2 files changed +12
-7
lines changed Original file line number Diff line number Diff line change 12
12
"require" : {
13
13
"php" : " ~7.1" ,
14
14
"phpstan/phpstan" : " ^0.11" ,
15
- "nikic/php-parser" : " ^4.0"
15
+ "nikic/php-parser" : " ^4.0" ,
16
+ "doctrine/persistence" : " ^1.1"
16
17
},
17
18
"require-dev" : {
18
19
"consistence/coding-standard" : " ^3.0.1" ,
Original file line number Diff line number Diff line change 3
3
namespace PHPStan \Type \Doctrine ;
4
4
5
5
use Doctrine \Common \Persistence \ObjectManager ;
6
- use Doctrine \ODM \MongoDB \Mapping \ClassMetadata as ODMMetadata ;
7
- use Doctrine \ORM \Mapping \ClassMetadata as ORMMetadata ;
8
6
use RuntimeException ;
9
7
use function file_exists ;
10
8
use function is_readable ;
@@ -49,12 +47,18 @@ public function getRepositoryClass(string $className): string
49
47
50
48
$ metadata = $ this ->objectManager ->getClassMetadata ($ className );
51
49
52
- if ($ metadata instanceof ORMMetadata) {
53
- return $ metadata ->customRepositoryClassName ?? $ this ->repositoryClass ;
50
+ $ ormMetadataClass = 'Doctrine\ORM\Mapping\ClassMetadata ' ;
51
+ if ($ metadata instanceof $ ormMetadataClass ) {
52
+ /** @var \Doctrine\ORM\Mapping\ClassMetadata $ormMetadata */
53
+ $ ormMetadata = $ metadata ;
54
+ return $ ormMetadata ->customRepositoryClassName ?? $ this ->repositoryClass ;
54
55
}
55
56
56
- if ($ metadata instanceof ODMMetadata) {
57
- return $ metadata ->customRepositoryClassName ?? $ this ->repositoryClass ;
57
+ $ odmMetadataClass = 'Doctrine\ODM\MongoDB\Mapping\ClassMetadata ' ;
58
+ if ($ metadata instanceof $ odmMetadataClass ) {
59
+ /** @var \Doctrine\ODM\MongoDB\Mapping\ClassMetadata $odmMetadata */
60
+ $ odmMetadata = $ metadata ;
61
+ return $ odmMetadata ->customRepositoryClassName ?? $ this ->repositoryClass ;
58
62
}
59
63
60
64
return $ this ->repositoryClass ;
You can’t perform that action at this time.
0 commit comments