5
5
use PhpParser \Node \Expr \StaticCall ;
6
6
use PhpParser \Node \Name ;
7
7
use PHPStan \Analyser \Scope ;
8
- use PHPStan \Broker \Broker ;
9
- use PHPStan \Reflection \BrokerAwareExtension ;
10
8
use PHPStan \Reflection \MethodReflection ;
9
+ use PHPStan \Reflection \ReflectionProvider ;
11
10
use PHPStan \Rules \Doctrine \ORM \DynamicQueryBuilderArgumentException ;
12
11
use PHPStan \ShouldNotHappenException ;
13
12
use PHPStan \Type \Doctrine \ArgumentsProcessor ;
16
15
use PHPStan \Type \Type ;
17
16
use function class_exists ;
18
17
19
- class NewExprDynamicReturnTypeExtension implements DynamicStaticMethodReturnTypeExtension, BrokerAwareExtension
18
+ class NewExprDynamicReturnTypeExtension implements DynamicStaticMethodReturnTypeExtension
20
19
{
21
20
22
21
/** @var ArgumentsProcessor */
@@ -25,21 +24,18 @@ class NewExprDynamicReturnTypeExtension implements DynamicStaticMethodReturnType
25
24
/** @var string */
26
25
private $ class ;
27
26
28
- /** @var Broker */
29
- private $ broker ;
27
+ /** @var ReflectionProvider */
28
+ private $ reflectionProvider ;
30
29
31
30
public function __construct (
32
31
ArgumentsProcessor $ argumentsProcessor ,
33
- string $ class
32
+ string $ class ,
33
+ ReflectionProvider $ reflectionProvider
34
34
)
35
35
{
36
36
$ this ->argumentsProcessor = $ argumentsProcessor ;
37
37
$ this ->class = $ class ;
38
- }
39
-
40
- public function setBroker (Broker $ broker ): void
41
- {
42
- $ this ->broker = $ broker ;
38
+ $ this ->reflectionProvider = $ reflectionProvider ;
43
39
}
44
40
45
41
public function getClass (): string
@@ -59,7 +55,7 @@ public function getTypeFromStaticMethodCall(MethodReflection $methodReflection,
59
55
}
60
56
61
57
$ className = $ scope ->resolveName ($ methodCall ->class );
62
- if (!$ this ->broker ->hasClass ($ className )) {
58
+ if (!$ this ->reflectionProvider ->hasClass ($ className )) {
63
59
return new ObjectType ($ className );
64
60
}
65
61
@@ -76,7 +72,7 @@ public function getTypeFromStaticMethodCall(MethodReflection $methodReflection,
76
72
)
77
73
);
78
74
} catch (DynamicQueryBuilderArgumentException $ e ) {
79
- return new ObjectType ($ this ->broker ->getClassName ($ className ));
75
+ return new ObjectType ($ this ->reflectionProvider ->getClassName ($ className ));
80
76
}
81
77
82
78
return new ExprType ($ className , $ exprObject );
0 commit comments