55use PhpParser \Node \Expr \StaticCall ;
66use PhpParser \Node \Name ;
77use PHPStan \Analyser \Scope ;
8- use PHPStan \Broker \Broker ;
9- use PHPStan \Reflection \BrokerAwareExtension ;
108use PHPStan \Reflection \MethodReflection ;
9+ use PHPStan \Reflection \ReflectionProvider ;
1110use PHPStan \Rules \Doctrine \ORM \DynamicQueryBuilderArgumentException ;
1211use PHPStan \ShouldNotHappenException ;
1312use PHPStan \Type \Doctrine \ArgumentsProcessor ;
1615use PHPStan \Type \Type ;
1716use function class_exists ;
1817
19- class NewExprDynamicReturnTypeExtension implements DynamicStaticMethodReturnTypeExtension, BrokerAwareExtension
18+ class NewExprDynamicReturnTypeExtension implements DynamicStaticMethodReturnTypeExtension
2019{
2120
2221 /** @var ArgumentsProcessor */
@@ -25,21 +24,18 @@ class NewExprDynamicReturnTypeExtension implements DynamicStaticMethodReturnType
2524 /** @var string */
2625 private $ class ;
2726
28- /** @var Broker */
29- private $ broker ;
27+ /** @var ReflectionProvider */
28+ private $ reflectionProvider ;
3029
3130 public function __construct (
3231 ArgumentsProcessor $ argumentsProcessor ,
33- string $ class
32+ string $ class ,
33+ ReflectionProvider $ reflectionProvider
3434 )
3535 {
3636 $ this ->argumentsProcessor = $ argumentsProcessor ;
3737 $ this ->class = $ class ;
38- }
39-
40- public function setBroker (Broker $ broker ): void
41- {
42- $ this ->broker = $ broker ;
38+ $ this ->reflectionProvider = $ reflectionProvider ;
4339 }
4440
4541 public function getClass (): string
@@ -59,7 +55,7 @@ public function getTypeFromStaticMethodCall(MethodReflection $methodReflection,
5955 }
6056
6157 $ className = $ scope ->resolveName ($ methodCall ->class );
62- if (!$ this ->broker ->hasClass ($ className )) {
58+ if (!$ this ->reflectionProvider ->hasClass ($ className )) {
6359 return new ObjectType ($ className );
6460 }
6561
@@ -76,7 +72,7 @@ public function getTypeFromStaticMethodCall(MethodReflection $methodReflection,
7672 )
7773 );
7874 } catch (DynamicQueryBuilderArgumentException $ e ) {
79- return new ObjectType ($ this ->broker ->getClassName ($ className ));
75+ return new ObjectType ($ this ->reflectionProvider ->getClassName ($ className ));
8076 }
8177
8278 return new ExprType ($ className , $ exprObject );
0 commit comments