From 63cec251637e873d896618cd73843c36f6e83f2f Mon Sep 17 00:00:00 2001 From: Ondrej Mirtes Date: Wed, 9 Jun 2021 15:42:17 +0200 Subject: [PATCH] Rewrite in backward compatibility compliant way --- .../BooleanInBooleanAndRuleTest.php | 7 +----- .../BooleanInBooleanNotRuleTest.php | 7 +----- .../BooleanInBooleanOrRuleTest.php | 7 +----- .../BooleanInElseIfConditionRuleTest.php | 7 +----- .../BooleanInIfConditionRuleTest.php | 7 +----- .../BooleanInTernaryOperatorRuleTest.php | 7 +----- ...ArithmeticIncrementOrDecrementRuleTest.php | 2 +- .../OperandsInArithmeticAdditionRuleTest.php | 2 +- .../OperandsInArithmeticDivisionRuleTest.php | 2 +- ...andsInArithmeticExponentiationRuleTest.php | 2 +- .../OperandsInArithmeticModuloRuleTest.php | 2 +- ...andsInArithmeticMultiplicationRuleTest.php | 2 +- ...perandsInArithmeticSubtractionRuleTest.php | 2 +- .../DynamicCallOnStaticMethodsRuleTest.php | 23 +------------------ 14 files changed, 14 insertions(+), 65 deletions(-) diff --git a/tests/Rules/BooleansInConditions/BooleanInBooleanAndRuleTest.php b/tests/Rules/BooleansInConditions/BooleanInBooleanAndRuleTest.php index d0173664..df62b648 100644 --- a/tests/Rules/BooleansInConditions/BooleanInBooleanAndRuleTest.php +++ b/tests/Rules/BooleansInConditions/BooleanInBooleanAndRuleTest.php @@ -15,12 +15,7 @@ protected function getRule(): Rule { return new BooleanInBooleanAndRule( new BooleanRuleHelper( - new RuleLevelHelper( - $this->createBroker(), - true, - false, - true - ) + self::getContainer()->getByType(RuleLevelHelper::class) ), true ); diff --git a/tests/Rules/BooleansInConditions/BooleanInBooleanNotRuleTest.php b/tests/Rules/BooleansInConditions/BooleanInBooleanNotRuleTest.php index 2d87c38d..eb887e7f 100644 --- a/tests/Rules/BooleansInConditions/BooleanInBooleanNotRuleTest.php +++ b/tests/Rules/BooleansInConditions/BooleanInBooleanNotRuleTest.php @@ -12,12 +12,7 @@ protected function getRule(): Rule { return new BooleanInBooleanNotRule( new BooleanRuleHelper( - new RuleLevelHelper( - $this->createBroker(), - true, - false, - true - ) + self::getContainer()->getByType(RuleLevelHelper::class) ) ); } diff --git a/tests/Rules/BooleansInConditions/BooleanInBooleanOrRuleTest.php b/tests/Rules/BooleansInConditions/BooleanInBooleanOrRuleTest.php index 9ddef28b..e2587d2d 100644 --- a/tests/Rules/BooleansInConditions/BooleanInBooleanOrRuleTest.php +++ b/tests/Rules/BooleansInConditions/BooleanInBooleanOrRuleTest.php @@ -15,12 +15,7 @@ protected function getRule(): Rule { return new BooleanInBooleanOrRule( new BooleanRuleHelper( - new RuleLevelHelper( - $this->createBroker(), - true, - false, - true - ) + self::getContainer()->getByType(RuleLevelHelper::class) ), true ); diff --git a/tests/Rules/BooleansInConditions/BooleanInElseIfConditionRuleTest.php b/tests/Rules/BooleansInConditions/BooleanInElseIfConditionRuleTest.php index 8a0b419f..880ca900 100644 --- a/tests/Rules/BooleansInConditions/BooleanInElseIfConditionRuleTest.php +++ b/tests/Rules/BooleansInConditions/BooleanInElseIfConditionRuleTest.php @@ -12,12 +12,7 @@ protected function getRule(): Rule { return new BooleanInElseIfConditionRule( new BooleanRuleHelper( - new RuleLevelHelper( - $this->createBroker(), - true, - false, - true - ) + self::getContainer()->getByType(RuleLevelHelper::class) ) ); } diff --git a/tests/Rules/BooleansInConditions/BooleanInIfConditionRuleTest.php b/tests/Rules/BooleansInConditions/BooleanInIfConditionRuleTest.php index 43715865..1922a0d5 100644 --- a/tests/Rules/BooleansInConditions/BooleanInIfConditionRuleTest.php +++ b/tests/Rules/BooleansInConditions/BooleanInIfConditionRuleTest.php @@ -12,12 +12,7 @@ protected function getRule(): Rule { return new BooleanInIfConditionRule( new BooleanRuleHelper( - new RuleLevelHelper( - $this->createBroker(), - true, - false, - true - ) + self::getContainer()->getByType(RuleLevelHelper::class) ) ); } diff --git a/tests/Rules/BooleansInConditions/BooleanInTernaryOperatorRuleTest.php b/tests/Rules/BooleansInConditions/BooleanInTernaryOperatorRuleTest.php index 661609dd..17c3fdd7 100644 --- a/tests/Rules/BooleansInConditions/BooleanInTernaryOperatorRuleTest.php +++ b/tests/Rules/BooleansInConditions/BooleanInTernaryOperatorRuleTest.php @@ -12,12 +12,7 @@ protected function getRule(): Rule { return new BooleanInTernaryOperatorRule( new BooleanRuleHelper( - new RuleLevelHelper( - $this->createBroker(), - true, - false, - true - ) + self::getContainer()->getByType(RuleLevelHelper::class) ) ); } diff --git a/tests/Rules/Operators/OperandInArithmeticIncrementOrDecrementRuleTest.php b/tests/Rules/Operators/OperandInArithmeticIncrementOrDecrementRuleTest.php index 73a8ef0f..4d041683 100644 --- a/tests/Rules/Operators/OperandInArithmeticIncrementOrDecrementRuleTest.php +++ b/tests/Rules/Operators/OperandInArithmeticIncrementOrDecrementRuleTest.php @@ -12,7 +12,7 @@ protected function getRule(): Rule { return $this->createRule( new OperatorRuleHelper( - new RuleLevelHelper($this->createBroker(), true, false, true) + self::getContainer()->getByType(RuleLevelHelper::class) ) ); } diff --git a/tests/Rules/Operators/OperandsInArithmeticAdditionRuleTest.php b/tests/Rules/Operators/OperandsInArithmeticAdditionRuleTest.php index 6bb643a0..d95d6864 100644 --- a/tests/Rules/Operators/OperandsInArithmeticAdditionRuleTest.php +++ b/tests/Rules/Operators/OperandsInArithmeticAdditionRuleTest.php @@ -13,7 +13,7 @@ protected function getRule(): Rule { return new OperandsInArithmeticAdditionRule( new OperatorRuleHelper( - new RuleLevelHelper($this->createBroker(), true, false, true) + self::getContainer()->getByType(RuleLevelHelper::class) ) ); } diff --git a/tests/Rules/Operators/OperandsInArithmeticDivisionRuleTest.php b/tests/Rules/Operators/OperandsInArithmeticDivisionRuleTest.php index a43a0bac..e3765921 100644 --- a/tests/Rules/Operators/OperandsInArithmeticDivisionRuleTest.php +++ b/tests/Rules/Operators/OperandsInArithmeticDivisionRuleTest.php @@ -12,7 +12,7 @@ protected function getRule(): Rule { return new OperandsInArithmeticDivisionRule( new OperatorRuleHelper( - new RuleLevelHelper($this->createBroker(), true, false, true) + self::getContainer()->getByType(RuleLevelHelper::class) ) ); } diff --git a/tests/Rules/Operators/OperandsInArithmeticExponentiationRuleTest.php b/tests/Rules/Operators/OperandsInArithmeticExponentiationRuleTest.php index f8c0f2d8..75ebae40 100644 --- a/tests/Rules/Operators/OperandsInArithmeticExponentiationRuleTest.php +++ b/tests/Rules/Operators/OperandsInArithmeticExponentiationRuleTest.php @@ -12,7 +12,7 @@ protected function getRule(): Rule { return new OperandsInArithmeticExponentiationRule( new OperatorRuleHelper( - new RuleLevelHelper($this->createBroker(), true, false, true) + self::getContainer()->getByType(RuleLevelHelper::class) ) ); } diff --git a/tests/Rules/Operators/OperandsInArithmeticModuloRuleTest.php b/tests/Rules/Operators/OperandsInArithmeticModuloRuleTest.php index a803c97e..73b07d69 100644 --- a/tests/Rules/Operators/OperandsInArithmeticModuloRuleTest.php +++ b/tests/Rules/Operators/OperandsInArithmeticModuloRuleTest.php @@ -12,7 +12,7 @@ protected function getRule(): Rule { return new OperandsInArithmeticModuloRule( new OperatorRuleHelper( - new RuleLevelHelper($this->createBroker(), true, false, true) + self::getContainer()->getByType(RuleLevelHelper::class) ) ); } diff --git a/tests/Rules/Operators/OperandsInArithmeticMultiplicationRuleTest.php b/tests/Rules/Operators/OperandsInArithmeticMultiplicationRuleTest.php index 643a3b3d..5299ce76 100644 --- a/tests/Rules/Operators/OperandsInArithmeticMultiplicationRuleTest.php +++ b/tests/Rules/Operators/OperandsInArithmeticMultiplicationRuleTest.php @@ -12,7 +12,7 @@ protected function getRule(): Rule { return new OperandsInArithmeticMultiplicationRule( new OperatorRuleHelper( - new RuleLevelHelper($this->createBroker(), true, false, true) + self::getContainer()->getByType(RuleLevelHelper::class) ) ); } diff --git a/tests/Rules/Operators/OperandsInArithmeticSubtractionRuleTest.php b/tests/Rules/Operators/OperandsInArithmeticSubtractionRuleTest.php index 522f2b9c..0005b4c0 100644 --- a/tests/Rules/Operators/OperandsInArithmeticSubtractionRuleTest.php +++ b/tests/Rules/Operators/OperandsInArithmeticSubtractionRuleTest.php @@ -12,7 +12,7 @@ protected function getRule(): Rule { return new OperandsInArithmeticSubtractionRule( new OperatorRuleHelper( - new RuleLevelHelper($this->createBroker(), true, false, true) + self::getContainer()->getByType(RuleLevelHelper::class) ) ); } diff --git a/tests/Rules/StrictCalls/DynamicCallOnStaticMethodsRuleTest.php b/tests/Rules/StrictCalls/DynamicCallOnStaticMethodsRuleTest.php index 9d5026b0..f9b0a93b 100644 --- a/tests/Rules/StrictCalls/DynamicCallOnStaticMethodsRuleTest.php +++ b/tests/Rules/StrictCalls/DynamicCallOnStaticMethodsRuleTest.php @@ -8,19 +8,13 @@ class DynamicCallOnStaticMethodsRuleTest extends \PHPStan\Testing\RuleTestCase { - /** @var bool */ - private $checkThisOnly; - protected function getRule(): Rule { - $broker = $this->createBroker(); - $ruleLevelHelper = new RuleLevelHelper($broker, true, $this->checkThisOnly, true); - return new DynamicCallOnStaticMethodsRule($ruleLevelHelper); + return new DynamicCallOnStaticMethodsRule(self::getContainer()->getByType(RuleLevelHelper::class)); } public function testRule(): void { - $this->checkThisOnly = false; $this->analyse([__DIR__ . '/data/dynamic-calls-on-static-methods.php'], [ [ 'Dynamic call to static method StrictCalls\ClassWithStaticMethod::foo().', @@ -41,19 +35,4 @@ public function testRule(): void ]); } - public function testRuleOnThisOnly(): void - { - $this->checkThisOnly = true; - $this->analyse([__DIR__ . '/data/dynamic-calls-on-static-methods.php'], [ - [ - 'Dynamic call to static method StrictCalls\ClassWithStaticMethod::foo().', - 14, - ], - [ - 'Dynamic call to static method StrictCalls\ClassUsingTrait::foo().', - 34, - ], - ]); - } - }