2
2
3
3
namespace mglaman \PHPStanDrupal \Type \EntityStorage ;
4
4
5
- use Drupal \Core \Config \Entity \ConfigEntityStorageInterface ;
6
- use Drupal \Core \Entity \ContentEntityStorageInterface ;
7
5
use Drupal \Core \Entity \EntityStorageInterface ;
8
6
use mglaman \PHPStanDrupal \Drupal \EntityDataRepository ;
9
- use mglaman \PHPStanDrupal \Type \EntityQuery \ConfigEntityQueryType ;
10
- use mglaman \PHPStanDrupal \Type \EntityQuery \ContentEntityQueryType ;
11
7
use PhpParser \Node \Expr \MethodCall ;
12
8
use PHPStan \Analyser \Scope ;
13
9
use PHPStan \Reflection \MethodReflection ;
14
10
use PHPStan \Reflection \ParametersAcceptorSelector ;
15
- use PHPStan \ShouldNotHappenException ;
16
11
use PHPStan \Type \ArrayType ;
17
12
use PHPStan \Type \DynamicMethodReturnTypeExtension ;
18
13
use PHPStan \Type \IntegerType ;
19
14
use PHPStan \Type \ObjectType ;
20
15
use PHPStan \Type \StringType ;
21
- use PHPStan \Type \Type ;
22
16
use PHPStan \Type \TypeCombinator ;
23
17
24
18
class EntityStorageDynamicReturnTypeExtension implements DynamicMethodReturnTypeExtension
@@ -49,7 +43,6 @@ public function isMethodSupported(MethodReflection $methodReflection): bool
49
43
'loadMultiple ' ,
50
44
'loadByProperties ' ,
51
45
'loadUnchanged ' ,
52
- 'getQuery ' ,
53
46
],
54
47
true
55
48
);
@@ -65,29 +58,6 @@ public function getTypeFromMethodCall(
65
58
return ParametersAcceptorSelector::selectSingle ($ methodReflection ->getVariants ())->getReturnType ();
66
59
}
67
60
68
- if ($ methodReflection ->getName () === 'getQuery ' ) {
69
- $ returnType = ParametersAcceptorSelector::selectSingle ($ methodReflection ->getVariants ())->getReturnType ();
70
- if (!$ returnType instanceof ObjectType) {
71
- return $ returnType ;
72
- }
73
-
74
- if ((new ObjectType (ContentEntityStorageInterface::class))->isSuperTypeOf ($ callerType )->yes ()) {
75
- return new ContentEntityQueryType (
76
- $ returnType ->getClassName (),
77
- $ returnType ->getSubtractedType (),
78
- $ returnType ->getClassReflection ()
79
- );
80
- }
81
- if ((new ObjectType (ConfigEntityStorageInterface::class))->isSuperTypeOf ($ callerType )->yes ()) {
82
- return new ConfigEntityQueryType (
83
- $ returnType ->getClassName (),
84
- $ returnType ->getSubtractedType (),
85
- $ returnType ->getClassReflection ()
86
- );
87
- }
88
- return $ returnType ;
89
- }
90
-
91
61
if (!$ callerType instanceof EntityStorageType) {
92
62
$ resolvedEntityType = $ this ->entityDataRepository ->resolveFromStorage ($ callerType );
93
63
if ($ resolvedEntityType === null ) {
0 commit comments