Skip to content

Commit 39e4b77

Browse files
staabmondrejmirtes
authored andcommitted
Use ReflectionProvider instead of Broker
1 parent bd84eb5 commit 39e4b77

File tree

2 files changed

+16
-21
lines changed

2 files changed

+16
-21
lines changed

src/Reflection/Doctrine/DoctrineSelectableClassReflectionExtension.php

+7-8
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,20 @@
22

33
namespace PHPStan\Reflection\Doctrine;
44

5-
use PHPStan\Broker\Broker;
6-
use PHPStan\Reflection\BrokerAwareExtension;
75
use PHPStan\Reflection\ClassReflection;
86
use PHPStan\Reflection\MethodReflection;
97
use PHPStan\Reflection\MethodsClassReflectionExtension;
8+
use PHPStan\Reflection\ReflectionProvider;
109

11-
class DoctrineSelectableClassReflectionExtension implements MethodsClassReflectionExtension, BrokerAwareExtension
10+
class DoctrineSelectableClassReflectionExtension implements MethodsClassReflectionExtension
1211
{
1312

14-
/** @var Broker */
15-
private $broker;
13+
/** @var ReflectionProvider */
14+
private $reflectionProvider;
1615

17-
public function setBroker(Broker $broker): void
16+
public function setBroker(ReflectionProvider $reflectionProvider): void
1817
{
19-
$this->broker = $broker;
18+
$this->reflectionProvider = $reflectionProvider;
2019
}
2120

2221
public function hasMethod(ClassReflection $classReflection, string $methodName): bool
@@ -27,7 +26,7 @@ public function hasMethod(ClassReflection $classReflection, string $methodName):
2726

2827
public function getMethod(ClassReflection $classReflection, string $methodName): MethodReflection
2928
{
30-
$selectableReflection = $this->broker->getClass('Doctrine\Common\Collections\Selectable');
29+
$selectableReflection = $this->reflectionProvider->getClass('Doctrine\Common\Collections\Selectable');
3130
return $selectableReflection->getNativeMethod($methodName);
3231
}
3332

src/Type/Doctrine/QueryBuilder/Expr/NewExprDynamicReturnTypeExtension.php

+9-13
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,8 @@
55
use PhpParser\Node\Expr\StaticCall;
66
use PhpParser\Node\Name;
77
use PHPStan\Analyser\Scope;
8-
use PHPStan\Broker\Broker;
9-
use PHPStan\Reflection\BrokerAwareExtension;
108
use PHPStan\Reflection\MethodReflection;
9+
use PHPStan\Reflection\ReflectionProvider;
1110
use PHPStan\Rules\Doctrine\ORM\DynamicQueryBuilderArgumentException;
1211
use PHPStan\ShouldNotHappenException;
1312
use PHPStan\Type\Doctrine\ArgumentsProcessor;
@@ -16,7 +15,7 @@
1615
use PHPStan\Type\Type;
1716
use 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

Comments
 (0)