From e5ccafb0dd8d835dd65d8d7a1a0d2b1b75414682 Mon Sep 17 00:00:00 2001 From: Ondrej Mirtes Date: Thu, 23 Sep 2021 12:50:47 +0200 Subject: [PATCH] Improve compatibility with PHPStan 1.0 --- phpstan.neon | 2 +- .../Deprecations/AccessDeprecatedPropertyRule.php | 12 ++++++------ .../AccessDeprecatedStaticPropertyRule.php | 12 ++++++------ .../Deprecations/CallToDeprecatedFunctionRule.php | 12 ++++++------ .../Deprecations/CallToDeprecatedMethodRule.php | 12 ++++++------ .../CallToDeprecatedStaticMethodRule.php | 12 ++++++------ src/Rules/Deprecations/DeprecatedClassHelper.php | 12 ++++++------ .../FetchingClassConstOfDeprecatedClassRule.php | 12 ++++++------ .../ImplementationOfDeprecatedInterfaceRule.php | 14 +++++++------- .../InheritanceOfDeprecatedClassRule.php | 14 +++++++------- .../InheritanceOfDeprecatedInterfaceRule.php | 14 +++++++------- .../InstantiationOfDeprecatedClassRule.php | 12 ++++++------ .../Deprecations/UsageOfDeprecatedTraitRule.php | 12 ++++++------ .../AccessDeprecatedPropertyRuleTest.php | 3 +-- .../AccessDeprecatedStaticPropertyRuleTest.php | 4 +--- .../CallToDeprecatedFunctionRuleTest.php | 3 +-- .../CallToDeprecatedMethodRuleTest.php | 3 +-- .../CallToDeprecatedStaticMethodRuleTest.php | 4 +--- ...FetchingClassConstOfDeprecatedClassRuleTest.php | 4 +--- ...ImplementationOfDeprecatedInterfaceRuleTest.php | 3 +-- .../InheritanceOfDeprecatedClassRuleTest.php | 3 +-- .../InheritanceOfDeprecatedInterfaceRuleTest.php | 3 +-- .../InstantiationOfDeprecatedClassRuleTest.php | 4 +--- ...intDeprecatedInClassMethodSignatureRuleTest.php | 4 +--- ...ypeHintDeprecatedInClosureSignatureRuleTest.php | 4 +--- ...peHintDeprecatedInFunctionSignatureRuleTest.php | 4 +--- .../UsageOfDeprecatedTraitRuleTest.php | 3 +-- 27 files changed, 90 insertions(+), 111 deletions(-) diff --git a/phpstan.neon b/phpstan.neon index d010cdf..a745ce7 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -3,5 +3,5 @@ includes: - vendor/phpstan/phpstan/conf/bleedingEdge.neon parameters: - excludes_analyse: + excludePaths: - tests/*/data/* diff --git a/src/Rules/Deprecations/AccessDeprecatedPropertyRule.php b/src/Rules/Deprecations/AccessDeprecatedPropertyRule.php index 086be48..2299f8f 100644 --- a/src/Rules/Deprecations/AccessDeprecatedPropertyRule.php +++ b/src/Rules/Deprecations/AccessDeprecatedPropertyRule.php @@ -6,7 +6,7 @@ use PhpParser\Node\Expr\PropertyFetch; use PhpParser\Node\Identifier; use PHPStan\Analyser\Scope; -use PHPStan\Broker\Broker; +use PHPStan\Reflection\ReflectionProvider; use PHPStan\Type\TypeUtils; /** @@ -15,12 +15,12 @@ class AccessDeprecatedPropertyRule implements \PHPStan\Rules\Rule { - /** @var Broker */ - private $broker; + /** @var ReflectionProvider */ + private $reflectionProvider; - public function __construct(Broker $broker) + public function __construct(ReflectionProvider $reflectionProvider) { - $this->broker = $broker; + $this->reflectionProvider = $reflectionProvider; } public function getNodeType(): string @@ -44,7 +44,7 @@ public function processNode(Node $node, Scope $scope): array foreach ($referencedClasses as $referencedClass) { try { - $classReflection = $this->broker->getClass($referencedClass); + $classReflection = $this->reflectionProvider->getClass($referencedClass); $propertyReflection = $classReflection->getProperty($propertyName, $scope); if ($propertyReflection->isDeprecated()->yes()) { diff --git a/src/Rules/Deprecations/AccessDeprecatedStaticPropertyRule.php b/src/Rules/Deprecations/AccessDeprecatedStaticPropertyRule.php index b273d29..ddf6d9a 100644 --- a/src/Rules/Deprecations/AccessDeprecatedStaticPropertyRule.php +++ b/src/Rules/Deprecations/AccessDeprecatedStaticPropertyRule.php @@ -7,7 +7,7 @@ use PhpParser\Node\Identifier; use PhpParser\Node\Name; use PHPStan\Analyser\Scope; -use PHPStan\Broker\Broker; +use PHPStan\Reflection\ReflectionProvider; use PHPStan\Rules\RuleLevelHelper; use PHPStan\Type\ErrorType; use PHPStan\Type\Type; @@ -18,15 +18,15 @@ class AccessDeprecatedStaticPropertyRule implements \PHPStan\Rules\Rule { - /** @var Broker */ - private $broker; + /** @var ReflectionProvider */ + private $reflectionProvider; /** @var RuleLevelHelper */ private $ruleLevelHelper; - public function __construct(Broker $broker, RuleLevelHelper $ruleLevelHelper) + public function __construct(ReflectionProvider $reflectionProvider, RuleLevelHelper $ruleLevelHelper) { - $this->broker = $broker; + $this->reflectionProvider = $reflectionProvider; $this->ruleLevelHelper = $ruleLevelHelper; } @@ -69,7 +69,7 @@ function (Type $type) use ($propertyName): bool { foreach ($referencedClasses as $referencedClass) { try { - $class = $this->broker->getClass($referencedClass); + $class = $this->reflectionProvider->getClass($referencedClass); $property = $class->getProperty($propertyName, $scope); } catch (\PHPStan\Broker\ClassNotFoundException $e) { continue; diff --git a/src/Rules/Deprecations/CallToDeprecatedFunctionRule.php b/src/Rules/Deprecations/CallToDeprecatedFunctionRule.php index 0483020..8080908 100644 --- a/src/Rules/Deprecations/CallToDeprecatedFunctionRule.php +++ b/src/Rules/Deprecations/CallToDeprecatedFunctionRule.php @@ -5,7 +5,7 @@ use PhpParser\Node; use PhpParser\Node\Expr\FuncCall; use PHPStan\Analyser\Scope; -use PHPStan\Broker\Broker; +use PHPStan\Reflection\ReflectionProvider; /** * @implements \PHPStan\Rules\Rule @@ -13,12 +13,12 @@ class CallToDeprecatedFunctionRule implements \PHPStan\Rules\Rule { - /** @var Broker */ - private $broker; + /** @var ReflectionProvider */ + private $reflectionProvider; - public function __construct(Broker $broker) + public function __construct(ReflectionProvider $reflectionProvider) { - $this->broker = $broker; + $this->reflectionProvider = $reflectionProvider; } public function getNodeType(): string @@ -37,7 +37,7 @@ public function processNode(Node $node, Scope $scope): array } try { - $function = $this->broker->getFunction($node->name, $scope); + $function = $this->reflectionProvider->getFunction($node->name, $scope); } catch (\PHPStan\Broker\FunctionNotFoundException $e) { // Other rules will notify if the function is not found return []; diff --git a/src/Rules/Deprecations/CallToDeprecatedMethodRule.php b/src/Rules/Deprecations/CallToDeprecatedMethodRule.php index e081270..bf1549c 100644 --- a/src/Rules/Deprecations/CallToDeprecatedMethodRule.php +++ b/src/Rules/Deprecations/CallToDeprecatedMethodRule.php @@ -6,7 +6,7 @@ use PhpParser\Node\Expr\MethodCall; use PhpParser\Node\Identifier; use PHPStan\Analyser\Scope; -use PHPStan\Broker\Broker; +use PHPStan\Reflection\ReflectionProvider; use PHPStan\Type\TypeUtils; /** @@ -15,12 +15,12 @@ class CallToDeprecatedMethodRule implements \PHPStan\Rules\Rule { - /** @var Broker */ - private $broker; + /** @var ReflectionProvider */ + private $reflectionProvider; - public function __construct(Broker $broker) + public function __construct(ReflectionProvider $reflectionProvider) { - $this->broker = $broker; + $this->reflectionProvider = $reflectionProvider; } public function getNodeType(): string @@ -44,7 +44,7 @@ public function processNode(Node $node, Scope $scope): array foreach ($referencedClasses as $referencedClass) { try { - $classReflection = $this->broker->getClass($referencedClass); + $classReflection = $this->reflectionProvider->getClass($referencedClass); $methodReflection = $classReflection->getMethod($methodName, $scope); if (!$methodReflection->isDeprecated()->yes()) { diff --git a/src/Rules/Deprecations/CallToDeprecatedStaticMethodRule.php b/src/Rules/Deprecations/CallToDeprecatedStaticMethodRule.php index f52ac4b..e9fe340 100644 --- a/src/Rules/Deprecations/CallToDeprecatedStaticMethodRule.php +++ b/src/Rules/Deprecations/CallToDeprecatedStaticMethodRule.php @@ -7,7 +7,7 @@ use PhpParser\Node\Identifier; use PhpParser\Node\Name; use PHPStan\Analyser\Scope; -use PHPStan\Broker\Broker; +use PHPStan\Reflection\ReflectionProvider; use PHPStan\Rules\RuleLevelHelper; use PHPStan\Type\ErrorType; use PHPStan\Type\Type; @@ -18,15 +18,15 @@ class CallToDeprecatedStaticMethodRule implements \PHPStan\Rules\Rule { - /** @var Broker */ - private $broker; + /** @var ReflectionProvider */ + private $reflectionProvider; /** @var RuleLevelHelper */ private $ruleLevelHelper; - public function __construct(Broker $broker, RuleLevelHelper $ruleLevelHelper) + public function __construct(ReflectionProvider $reflectionProvider, RuleLevelHelper $ruleLevelHelper) { - $this->broker = $broker; + $this->reflectionProvider = $reflectionProvider; $this->ruleLevelHelper = $ruleLevelHelper; } @@ -71,7 +71,7 @@ function (Type $type) use ($methodName): bool { foreach ($referencedClasses as $referencedClass) { try { - $class = $this->broker->getClass($referencedClass); + $class = $this->reflectionProvider->getClass($referencedClass); $methodReflection = $class->getMethod($methodName, $scope); } catch (\PHPStan\Broker\ClassNotFoundException $e) { continue; diff --git a/src/Rules/Deprecations/DeprecatedClassHelper.php b/src/Rules/Deprecations/DeprecatedClassHelper.php index 71af961..17816a2 100644 --- a/src/Rules/Deprecations/DeprecatedClassHelper.php +++ b/src/Rules/Deprecations/DeprecatedClassHelper.php @@ -2,18 +2,18 @@ namespace PHPStan\Rules\Deprecations; -use PHPStan\Broker\Broker; use PHPStan\Reflection\ClassReflection; +use PHPStan\Reflection\ReflectionProvider; class DeprecatedClassHelper { - /** @var Broker */ - private $broker; + /** @var ReflectionProvider */ + private $reflectionProvider; - public function __construct(Broker $broker) + public function __construct(ReflectionProvider $reflectionProvider) { - $this->broker = $broker; + $this->reflectionProvider = $reflectionProvider; } public function getClassType(ClassReflection $class): string @@ -44,7 +44,7 @@ public function filterDeprecatedClasses(array $referencedClasses): array $deprecatedClasses = []; foreach ($referencedClasses as $referencedClass) { try { - $class = $this->broker->getClass($referencedClass); + $class = $this->reflectionProvider->getClass($referencedClass); } catch (\PHPStan\Broker\ClassNotFoundException $e) { continue; } diff --git a/src/Rules/Deprecations/FetchingClassConstOfDeprecatedClassRule.php b/src/Rules/Deprecations/FetchingClassConstOfDeprecatedClassRule.php index 362db9c..f60c8e8 100644 --- a/src/Rules/Deprecations/FetchingClassConstOfDeprecatedClassRule.php +++ b/src/Rules/Deprecations/FetchingClassConstOfDeprecatedClassRule.php @@ -7,7 +7,7 @@ use PhpParser\Node\Identifier; use PhpParser\Node\Name; use PHPStan\Analyser\Scope; -use PHPStan\Broker\Broker; +use PHPStan\Reflection\ReflectionProvider; use PHPStan\Rules\RuleLevelHelper; use PHPStan\Type\ErrorType; use PHPStan\Type\Type; @@ -18,15 +18,15 @@ class FetchingClassConstOfDeprecatedClassRule implements \PHPStan\Rules\Rule { - /** @var Broker */ - private $broker; + /** @var ReflectionProvider */ + private $reflectionProvider; /** @var RuleLevelHelper */ private $ruleLevelHelper; - public function __construct(Broker $broker, RuleLevelHelper $ruleLevelHelper) + public function __construct(ReflectionProvider $reflectionProvider, RuleLevelHelper $ruleLevelHelper) { - $this->broker = $broker; + $this->reflectionProvider = $reflectionProvider; $this->ruleLevelHelper = $ruleLevelHelper; } @@ -71,7 +71,7 @@ function (Type $type) use ($constantName): bool { foreach ($referencedClasses as $referencedClass) { try { - $class = $this->broker->getClass($referencedClass); + $class = $this->reflectionProvider->getClass($referencedClass); } catch (\PHPStan\Broker\ClassNotFoundException $e) { continue; } diff --git a/src/Rules/Deprecations/ImplementationOfDeprecatedInterfaceRule.php b/src/Rules/Deprecations/ImplementationOfDeprecatedInterfaceRule.php index 9472ff2..187f009 100644 --- a/src/Rules/Deprecations/ImplementationOfDeprecatedInterfaceRule.php +++ b/src/Rules/Deprecations/ImplementationOfDeprecatedInterfaceRule.php @@ -5,7 +5,7 @@ use PhpParser\Node; use PhpParser\Node\Stmt\Class_; use PHPStan\Analyser\Scope; -use PHPStan\Broker\Broker; +use PHPStan\Reflection\ReflectionProvider; /** * @implements \PHPStan\Rules\Rule @@ -13,12 +13,12 @@ class ImplementationOfDeprecatedInterfaceRule implements \PHPStan\Rules\Rule { - /** @var Broker */ - private $broker; + /** @var ReflectionProvider */ + private $reflectionProvider; - public function __construct(Broker $broker) + public function __construct(ReflectionProvider $reflectionProvider) { - $this->broker = $broker; + $this->reflectionProvider = $reflectionProvider; } public function getNodeType(): string @@ -39,7 +39,7 @@ public function processNode(Node $node, Scope $scope): array : (string) $node->name; try { - $class = $this->broker->getClass($className); + $class = $this->reflectionProvider->getClass($className); } catch (\PHPStan\Broker\ClassNotFoundException $e) { return []; } @@ -52,7 +52,7 @@ public function processNode(Node $node, Scope $scope): array $interfaceName = (string) $implement; try { - $interface = $this->broker->getClass($interfaceName); + $interface = $this->reflectionProvider->getClass($interfaceName); if ($interface->isDeprecated()) { $description = $interface->getDeprecatedDescription(); diff --git a/src/Rules/Deprecations/InheritanceOfDeprecatedClassRule.php b/src/Rules/Deprecations/InheritanceOfDeprecatedClassRule.php index df33f02..b2112f6 100644 --- a/src/Rules/Deprecations/InheritanceOfDeprecatedClassRule.php +++ b/src/Rules/Deprecations/InheritanceOfDeprecatedClassRule.php @@ -5,7 +5,7 @@ use PhpParser\Node; use PhpParser\Node\Stmt\Class_; use PHPStan\Analyser\Scope; -use PHPStan\Broker\Broker; +use PHPStan\Reflection\ReflectionProvider; /** * @implements \PHPStan\Rules\Rule @@ -13,12 +13,12 @@ class InheritanceOfDeprecatedClassRule implements \PHPStan\Rules\Rule { - /** @var Broker */ - private $broker; + /** @var ReflectionProvider */ + private $reflectionProvider; - public function __construct(Broker $broker) + public function __construct(ReflectionProvider $reflectionProvider) { - $this->broker = $broker; + $this->reflectionProvider = $reflectionProvider; } public function getNodeType(): string @@ -43,7 +43,7 @@ public function processNode(Node $node, Scope $scope): array : (string) $node->name; try { - $class = $this->broker->getClass($className); + $class = $this->reflectionProvider->getClass($className); } catch (\PHPStan\Broker\ClassNotFoundException $e) { return []; } @@ -51,7 +51,7 @@ public function processNode(Node $node, Scope $scope): array $parentClassName = (string) $node->extends; try { - $parentClass = $this->broker->getClass($parentClassName); + $parentClass = $this->reflectionProvider->getClass($parentClassName); $description = $parentClass->getDeprecatedDescription(); if ($parentClass->isDeprecated()) { if (!$class->isAnonymous()) { diff --git a/src/Rules/Deprecations/InheritanceOfDeprecatedInterfaceRule.php b/src/Rules/Deprecations/InheritanceOfDeprecatedInterfaceRule.php index 564bde1..a79e25c 100644 --- a/src/Rules/Deprecations/InheritanceOfDeprecatedInterfaceRule.php +++ b/src/Rules/Deprecations/InheritanceOfDeprecatedInterfaceRule.php @@ -5,7 +5,7 @@ use PhpParser\Node; use PhpParser\Node\Stmt\Interface_; use PHPStan\Analyser\Scope; -use PHPStan\Broker\Broker; +use PHPStan\Reflection\ReflectionProvider; /** * @implements \PHPStan\Rules\Rule @@ -13,12 +13,12 @@ class InheritanceOfDeprecatedInterfaceRule implements \PHPStan\Rules\Rule { - /** @var Broker */ - private $broker; + /** @var ReflectionProvider */ + private $reflectionProvider; - public function __construct(Broker $broker) + public function __construct(ReflectionProvider $reflectionProvider) { - $this->broker = $broker; + $this->reflectionProvider = $reflectionProvider; } public function getNodeType(): string @@ -37,7 +37,7 @@ public function processNode(Node $node, Scope $scope): array : (string) $node->name; try { - $interface = $this->broker->getClass($interfaceName); + $interface = $this->reflectionProvider->getClass($interfaceName); } catch (\PHPStan\Broker\ClassNotFoundException $e) { return []; } @@ -52,7 +52,7 @@ public function processNode(Node $node, Scope $scope): array $parentInterfaceName = (string) $parentInterfaceName; try { - $parentInterface = $this->broker->getClass($parentInterfaceName); + $parentInterface = $this->reflectionProvider->getClass($parentInterfaceName); if (!$parentInterface->isDeprecated()) { continue; diff --git a/src/Rules/Deprecations/InstantiationOfDeprecatedClassRule.php b/src/Rules/Deprecations/InstantiationOfDeprecatedClassRule.php index cad353f..d47a707 100644 --- a/src/Rules/Deprecations/InstantiationOfDeprecatedClassRule.php +++ b/src/Rules/Deprecations/InstantiationOfDeprecatedClassRule.php @@ -7,7 +7,7 @@ use PhpParser\Node\Name; use PhpParser\Node\Stmt\Class_; use PHPStan\Analyser\Scope; -use PHPStan\Broker\Broker; +use PHPStan\Reflection\ReflectionProvider; use PHPStan\Rules\RuleLevelHelper; use PHPStan\Type\ErrorType; @@ -17,15 +17,15 @@ class InstantiationOfDeprecatedClassRule implements \PHPStan\Rules\Rule { - /** @var Broker */ - private $broker; + /** @var ReflectionProvider */ + private $reflectionProvider; /** @var RuleLevelHelper */ private $ruleLevelHelper; - public function __construct(Broker $broker, RuleLevelHelper $ruleLevelHelper) + public function __construct(ReflectionProvider $reflectionProvider, RuleLevelHelper $ruleLevelHelper) { - $this->broker = $broker; + $this->reflectionProvider = $reflectionProvider; $this->ruleLevelHelper = $ruleLevelHelper; } @@ -71,7 +71,7 @@ function (): bool { foreach ($referencedClasses as $referencedClass) { try { - $class = $this->broker->getClass($referencedClass); + $class = $this->reflectionProvider->getClass($referencedClass); } catch (\PHPStan\Broker\ClassNotFoundException $e) { continue; } diff --git a/src/Rules/Deprecations/UsageOfDeprecatedTraitRule.php b/src/Rules/Deprecations/UsageOfDeprecatedTraitRule.php index 9e2f905..13d2d45 100644 --- a/src/Rules/Deprecations/UsageOfDeprecatedTraitRule.php +++ b/src/Rules/Deprecations/UsageOfDeprecatedTraitRule.php @@ -5,7 +5,7 @@ use PhpParser\Node; use PhpParser\Node\Stmt\TraitUse; use PHPStan\Analyser\Scope; -use PHPStan\Broker\Broker; +use PHPStan\Reflection\ReflectionProvider; /** * @implements \PHPStan\Rules\Rule @@ -13,12 +13,12 @@ class UsageOfDeprecatedTraitRule implements \PHPStan\Rules\Rule { - /** @var Broker */ - private $broker; + /** @var ReflectionProvider */ + private $reflectionProvider; - public function __construct(Broker $broker) + public function __construct(ReflectionProvider $reflectionProvider) { - $this->broker = $broker; + $this->reflectionProvider = $reflectionProvider; } public function getNodeType(): string @@ -44,7 +44,7 @@ public function processNode(Node $node, Scope $scope): array $traitName = (string) $traitNameNode; try { - $trait = $this->broker->getClass($traitName); + $trait = $this->reflectionProvider->getClass($traitName); if (!$trait->isDeprecated()) { continue; } diff --git a/tests/Rules/Deprecations/AccessDeprecatedPropertyRuleTest.php b/tests/Rules/Deprecations/AccessDeprecatedPropertyRuleTest.php index 47b92f2..fe9c719 100644 --- a/tests/Rules/Deprecations/AccessDeprecatedPropertyRuleTest.php +++ b/tests/Rules/Deprecations/AccessDeprecatedPropertyRuleTest.php @@ -10,8 +10,7 @@ class AccessDeprecatedPropertyRuleTest extends \PHPStan\Testing\RuleTestCase protected function getRule(): \PHPStan\Rules\Rule { - $broker = $this->createBroker(); - return new AccessDeprecatedPropertyRule($broker); + return new AccessDeprecatedPropertyRule($this->createReflectionProvider()); } public function testAccessDeprecatedProperty(): void diff --git a/tests/Rules/Deprecations/AccessDeprecatedStaticPropertyRuleTest.php b/tests/Rules/Deprecations/AccessDeprecatedStaticPropertyRuleTest.php index 713874e..a24ca27 100644 --- a/tests/Rules/Deprecations/AccessDeprecatedStaticPropertyRuleTest.php +++ b/tests/Rules/Deprecations/AccessDeprecatedStaticPropertyRuleTest.php @@ -12,9 +12,7 @@ class AccessDeprecatedStaticPropertyRuleTest extends \PHPStan\Testing\RuleTestCa protected function getRule(): \PHPStan\Rules\Rule { - $broker = $this->createBroker(); - - return new AccessDeprecatedStaticPropertyRule($broker, self::getContainer()->getByType(RuleLevelHelper::class)); + return new AccessDeprecatedStaticPropertyRule($this->createReflectionProvider(), self::getContainer()->getByType(RuleLevelHelper::class)); } public function testAccessDeprecatedStaticProperty(): void diff --git a/tests/Rules/Deprecations/CallToDeprecatedFunctionRuleTest.php b/tests/Rules/Deprecations/CallToDeprecatedFunctionRuleTest.php index e22f4c9..54b3cee 100644 --- a/tests/Rules/Deprecations/CallToDeprecatedFunctionRuleTest.php +++ b/tests/Rules/Deprecations/CallToDeprecatedFunctionRuleTest.php @@ -10,8 +10,7 @@ class CallToDeprecatedFunctionRuleTest extends \PHPStan\Testing\RuleTestCase protected function getRule(): \PHPStan\Rules\Rule { - $broker = $this->createBroker(); - return new CallToDeprecatedFunctionRule($broker); + return new CallToDeprecatedFunctionRule($this->createReflectionProvider()); } public function testDeprecatedFunctionCall(): void diff --git a/tests/Rules/Deprecations/CallToDeprecatedMethodRuleTest.php b/tests/Rules/Deprecations/CallToDeprecatedMethodRuleTest.php index 70a7824..f660fad 100644 --- a/tests/Rules/Deprecations/CallToDeprecatedMethodRuleTest.php +++ b/tests/Rules/Deprecations/CallToDeprecatedMethodRuleTest.php @@ -10,8 +10,7 @@ class CallToDeprecatedMethodRuleTest extends \PHPStan\Testing\RuleTestCase protected function getRule(): \PHPStan\Rules\Rule { - $broker = $this->createBroker(); - return new CallToDeprecatedMethodRule($broker); + return new CallToDeprecatedMethodRule($this->createReflectionProvider()); } public function testDeprecatedMethodCall(): void diff --git a/tests/Rules/Deprecations/CallToDeprecatedStaticMethodRuleTest.php b/tests/Rules/Deprecations/CallToDeprecatedStaticMethodRuleTest.php index 68ccda1..45a48f3 100644 --- a/tests/Rules/Deprecations/CallToDeprecatedStaticMethodRuleTest.php +++ b/tests/Rules/Deprecations/CallToDeprecatedStaticMethodRuleTest.php @@ -12,9 +12,7 @@ class CallToDeprecatedStaticMethodRuleTest extends \PHPStan\Testing\RuleTestCase protected function getRule(): \PHPStan\Rules\Rule { - $broker = $this->createBroker(); - - return new CallToDeprecatedStaticMethodRule($broker, self::getContainer()->getByType(RuleLevelHelper::class)); + return new CallToDeprecatedStaticMethodRule($this->createReflectionProvider(), self::getContainer()->getByType(RuleLevelHelper::class)); } public function testDeprecatedStaticMethodCall(): void diff --git a/tests/Rules/Deprecations/FetchingClassConstOfDeprecatedClassRuleTest.php b/tests/Rules/Deprecations/FetchingClassConstOfDeprecatedClassRuleTest.php index de1ff6e..9ae3eb0 100644 --- a/tests/Rules/Deprecations/FetchingClassConstOfDeprecatedClassRuleTest.php +++ b/tests/Rules/Deprecations/FetchingClassConstOfDeprecatedClassRuleTest.php @@ -12,9 +12,7 @@ class FetchingClassConstOfDeprecatedClassRuleTest extends \PHPStan\Testing\RuleT protected function getRule(): \PHPStan\Rules\Rule { - $broker = $this->createBroker(); - - return new FetchingClassConstOfDeprecatedClassRule($broker, self::getContainer()->getByType(RuleLevelHelper::class)); + return new FetchingClassConstOfDeprecatedClassRule($this->createReflectionProvider(), self::getContainer()->getByType(RuleLevelHelper::class)); } public function testFetchingClassConstOfDeprecatedClass(): void diff --git a/tests/Rules/Deprecations/ImplementationOfDeprecatedInterfaceRuleTest.php b/tests/Rules/Deprecations/ImplementationOfDeprecatedInterfaceRuleTest.php index fe575a4..c0a1e23 100644 --- a/tests/Rules/Deprecations/ImplementationOfDeprecatedInterfaceRuleTest.php +++ b/tests/Rules/Deprecations/ImplementationOfDeprecatedInterfaceRuleTest.php @@ -10,8 +10,7 @@ class ImplementationOfDeprecatedInterfaceRuleTest extends \PHPStan\Testing\RuleT protected function getRule(): \PHPStan\Rules\Rule { - $broker = $this->createBroker(); - return new ImplementationOfDeprecatedInterfaceRule($broker); + return new ImplementationOfDeprecatedInterfaceRule($this->createReflectionProvider()); } public function testImplementationOfDeprecatedInterfacesInClasses(): void diff --git a/tests/Rules/Deprecations/InheritanceOfDeprecatedClassRuleTest.php b/tests/Rules/Deprecations/InheritanceOfDeprecatedClassRuleTest.php index 51dd336..43e8013 100644 --- a/tests/Rules/Deprecations/InheritanceOfDeprecatedClassRuleTest.php +++ b/tests/Rules/Deprecations/InheritanceOfDeprecatedClassRuleTest.php @@ -10,8 +10,7 @@ class InheritanceOfDeprecatedClassRuleTest extends \PHPStan\Testing\RuleTestCase protected function getRule(): \PHPStan\Rules\Rule { - $broker = $this->createBroker(); - return new InheritanceOfDeprecatedClassRule($broker); + return new InheritanceOfDeprecatedClassRule($this->createReflectionProvider()); } public function testInheritanceOfDeprecatedClassInClasses(): void diff --git a/tests/Rules/Deprecations/InheritanceOfDeprecatedInterfaceRuleTest.php b/tests/Rules/Deprecations/InheritanceOfDeprecatedInterfaceRuleTest.php index c587477..61a8ed3 100644 --- a/tests/Rules/Deprecations/InheritanceOfDeprecatedInterfaceRuleTest.php +++ b/tests/Rules/Deprecations/InheritanceOfDeprecatedInterfaceRuleTest.php @@ -10,8 +10,7 @@ class InheritanceOfDeprecatedInterfaceRuleTest extends \PHPStan\Testing\RuleTest protected function getRule(): \PHPStan\Rules\Rule { - $broker = $this->createBroker(); - return new InheritanceOfDeprecatedInterfaceRule($broker); + return new InheritanceOfDeprecatedInterfaceRule($this->createReflectionProvider()); } public function testInheritanceOfDeprecatedInterfaces(): void diff --git a/tests/Rules/Deprecations/InstantiationOfDeprecatedClassRuleTest.php b/tests/Rules/Deprecations/InstantiationOfDeprecatedClassRuleTest.php index ee620c5..099835f 100644 --- a/tests/Rules/Deprecations/InstantiationOfDeprecatedClassRuleTest.php +++ b/tests/Rules/Deprecations/InstantiationOfDeprecatedClassRuleTest.php @@ -12,9 +12,7 @@ class InstantiationOfDeprecatedClassRuleTest extends \PHPStan\Testing\RuleTestCa protected function getRule(): \PHPStan\Rules\Rule { - $broker = $this->createBroker(); - - return new InstantiationOfDeprecatedClassRule($broker, self::getContainer()->getByType(RuleLevelHelper::class)); + return new InstantiationOfDeprecatedClassRule($this->createReflectionProvider(), self::getContainer()->getByType(RuleLevelHelper::class)); } public function testInstantiationOfDeprecatedClass(): void diff --git a/tests/Rules/Deprecations/TypeHintDeprecatedInClassMethodSignatureRuleTest.php b/tests/Rules/Deprecations/TypeHintDeprecatedInClassMethodSignatureRuleTest.php index f48f77e..38cf3e5 100644 --- a/tests/Rules/Deprecations/TypeHintDeprecatedInClassMethodSignatureRuleTest.php +++ b/tests/Rules/Deprecations/TypeHintDeprecatedInClassMethodSignatureRuleTest.php @@ -10,9 +10,7 @@ class TypeHintDeprecatedInClassMethodSignatureRuleTest extends \PHPStan\Testing\ protected function getRule(): \PHPStan\Rules\Rule { - $broker = $this->createBroker(); - - return new TypeHintDeprecatedInClassMethodSignatureRule(new DeprecatedClassHelper($broker)); + return new TypeHintDeprecatedInClassMethodSignatureRule(new DeprecatedClassHelper($this->createReflectionProvider())); } public function test(): void diff --git a/tests/Rules/Deprecations/TypeHintDeprecatedInClosureSignatureRuleTest.php b/tests/Rules/Deprecations/TypeHintDeprecatedInClosureSignatureRuleTest.php index 1e01877..6da716b 100644 --- a/tests/Rules/Deprecations/TypeHintDeprecatedInClosureSignatureRuleTest.php +++ b/tests/Rules/Deprecations/TypeHintDeprecatedInClosureSignatureRuleTest.php @@ -10,9 +10,7 @@ class TypeHintDeprecatedInClosureSignatureRuleTest extends \PHPStan\Testing\Rule protected function getRule(): \PHPStan\Rules\Rule { - $broker = $this->createBroker(); - - return new TypeHintDeprecatedInClosureSignatureRule(new DeprecatedClassHelper($broker)); + return new TypeHintDeprecatedInClosureSignatureRule(new DeprecatedClassHelper($this->createReflectionProvider())); } public function test(): void diff --git a/tests/Rules/Deprecations/TypeHintDeprecatedInFunctionSignatureRuleTest.php b/tests/Rules/Deprecations/TypeHintDeprecatedInFunctionSignatureRuleTest.php index ceb3fc6..eeef36c 100644 --- a/tests/Rules/Deprecations/TypeHintDeprecatedInFunctionSignatureRuleTest.php +++ b/tests/Rules/Deprecations/TypeHintDeprecatedInFunctionSignatureRuleTest.php @@ -10,9 +10,7 @@ class TypeHintDeprecatedInFunctionSignatureRuleTest extends \PHPStan\Testing\Rul protected function getRule(): \PHPStan\Rules\Rule { - $broker = $this->createBroker(); - - return new TypeHintDeprecatedInFunctionSignatureRule(new DeprecatedClassHelper($broker)); + return new TypeHintDeprecatedInFunctionSignatureRule(new DeprecatedClassHelper($this->createReflectionProvider())); } public function test(): void diff --git a/tests/Rules/Deprecations/UsageOfDeprecatedTraitRuleTest.php b/tests/Rules/Deprecations/UsageOfDeprecatedTraitRuleTest.php index 908d200..4b473c5 100644 --- a/tests/Rules/Deprecations/UsageOfDeprecatedTraitRuleTest.php +++ b/tests/Rules/Deprecations/UsageOfDeprecatedTraitRuleTest.php @@ -10,8 +10,7 @@ class UsageOfDeprecatedTraitRuleTest extends \PHPStan\Testing\RuleTestCase protected function getRule(): \PHPStan\Rules\Rule { - $broker = $this->createBroker(); - return new UsageOfDeprecatedTraitRule($broker); + return new UsageOfDeprecatedTraitRule($this->createReflectionProvider()); } public function testUsageOfDeprecatedTrait(): void