File tree Expand file tree Collapse file tree 2 files changed +40
-0
lines changed Expand file tree Collapse file tree 2 files changed +40
-0
lines changed Original file line number Diff line number Diff line change @@ -21,6 +21,10 @@ services:
21
21
repositoryClass : %doctrine.repositoryClass%
22
22
tags :
23
23
- phpstan.broker.dynamicMethodReturnTypeExtension
24
+ -
25
+ class : PHPStan\Type\Doctrine\EntityManagerMergeDynamicReturnTypeExtension
26
+ tags :
27
+ - phpstan.broker.dynamicMethodReturnTypeExtension
24
28
-
25
29
class : PHPStan\Type\Doctrine\EntityRepositoryDynamicReturnTypeExtension
26
30
tags :
Original file line number Diff line number Diff line change
1
+ <?php declare (strict_types = 1 );
2
+
3
+ namespace PHPStan \Type \Doctrine ;
4
+
5
+ use PhpParser \Node \Expr \MethodCall ;
6
+ use PHPStan \Analyser \Scope ;
7
+ use PHPStan \Reflection \MethodReflection ;
8
+ use PHPStan \Type \Type ;
9
+
10
+ class EntityManagerMergeDynamicReturnTypeExtension implements \PHPStan \Type \DynamicMethodReturnTypeExtension
11
+ {
12
+
13
+ public function getClass (): string
14
+ {
15
+ return \Doctrine \ORM \EntityManager::class;
16
+ }
17
+
18
+ public function isMethodSupported (MethodReflection $ methodReflection ): bool
19
+ {
20
+ return $ methodReflection ->getName () === 'merge ' ;
21
+ }
22
+
23
+ public function getTypeFromMethodCall (
24
+ MethodReflection $ methodReflection ,
25
+ MethodCall $ methodCall ,
26
+ Scope $ scope
27
+ ): Type
28
+ {
29
+ if (count ($ methodCall ->args ) === 0 ) {
30
+ return $ methodReflection ->getReturnType ();
31
+ }
32
+
33
+ return $ scope ->getType ($ methodCall ->args [0 ]->value );
34
+ }
35
+
36
+ }
You can’t perform that action at this time.
0 commit comments