From 1fbc5dd38cbb6fde6b890ce2fe8388c4b823e2b9 Mon Sep 17 00:00:00 2001 From: Mikko Pesari Date: Tue, 24 Feb 2026 14:01:53 +0200 Subject: [PATCH 1/2] Test BcMath\Number operators --- ...hmeticIncrementOrDecrementRuleTestCase.php | 13 + ...erandInArithmeticPostDecrementRuleTest.php | 13 + ...erandInArithmeticPostIncrementRuleTest.php | 13 + ...perandInArithmeticPreDecrementRuleTest.php | 13 + ...perandInArithmeticPreIncrementRuleTest.php | 13 + .../OperandInArithmeticUnaryMinusRuleTest.php | 8 + .../OperandInArithmeticUnaryPlusRuleTest.php | 8 + .../OperandsInArithmeticAdditionRuleTest.php | 21 ++ .../OperandsInArithmeticDivisionRuleTest.php | 21 ++ ...andsInArithmeticExponentiationRuleTest.php | 21 ++ .../OperandsInArithmeticModuloRuleTest.php | 21 ++ ...andsInArithmeticMultiplicationRuleTest.php | 21 ++ ...perandsInArithmeticSubtractionRuleTest.php | 21 ++ .../data/increment-decrement-bcmath.php | 21 ++ .../Rules/Operators/data/operators-bcmath.php | 267 ++++++++++++++++++ 15 files changed, 495 insertions(+) create mode 100644 tests/Rules/Operators/data/increment-decrement-bcmath.php create mode 100644 tests/Rules/Operators/data/operators-bcmath.php diff --git a/tests/Rules/Operators/OperandInArithmeticIncrementOrDecrementRuleTestCase.php b/tests/Rules/Operators/OperandInArithmeticIncrementOrDecrementRuleTestCase.php index a1206dca..9571a62e 100644 --- a/tests/Rules/Operators/OperandInArithmeticIncrementOrDecrementRuleTestCase.php +++ b/tests/Rules/Operators/OperandInArithmeticIncrementOrDecrementRuleTestCase.php @@ -27,6 +27,14 @@ public function testRule(): void $this->analyse([__DIR__ . '/data/increment-decrement.php'], $this->getExpectedErrors()); } + /** + * @requires PHP >= 8.4 + */ + public function testRuleWithBcMath(): void + { + $this->analyse([__DIR__ . '/data/increment-decrement-bcmath.php'], $this->getExpectedErrorsWithBcMath()); + } + /** * @return T */ @@ -37,4 +45,9 @@ abstract protected function createRule(OperatorRuleHelper $helper): Rule; */ abstract protected function getExpectedErrors(): array; + /** + * @return list + */ + abstract protected function getExpectedErrorsWithBcMath(): array; + } diff --git a/tests/Rules/Operators/OperandInArithmeticPostDecrementRuleTest.php b/tests/Rules/Operators/OperandInArithmeticPostDecrementRuleTest.php index c4ea1569..67a1e0a8 100644 --- a/tests/Rules/Operators/OperandInArithmeticPostDecrementRuleTest.php +++ b/tests/Rules/Operators/OperandInArithmeticPostDecrementRuleTest.php @@ -44,4 +44,17 @@ protected function getExpectedErrors(): array ]; } + /** + * {@inheritdoc} + */ + protected function getExpectedErrorsWithBcMath(): array + { + return [ + [ + 'Only numeric types are allowed in post-decrement, BcMath\Number given.', + 8, + ], + ]; + } + } diff --git a/tests/Rules/Operators/OperandInArithmeticPostIncrementRuleTest.php b/tests/Rules/Operators/OperandInArithmeticPostIncrementRuleTest.php index 94357e60..1548980c 100644 --- a/tests/Rules/Operators/OperandInArithmeticPostIncrementRuleTest.php +++ b/tests/Rules/Operators/OperandInArithmeticPostIncrementRuleTest.php @@ -40,4 +40,17 @@ protected function getExpectedErrors(): array ]; } + /** + * {@inheritdoc} + */ + protected function getExpectedErrorsWithBcMath(): array + { + return [ + [ + 'Only numeric types are allowed in post-increment, BcMath\Number given.', + 12, + ], + ]; + } + } diff --git a/tests/Rules/Operators/OperandInArithmeticPreDecrementRuleTest.php b/tests/Rules/Operators/OperandInArithmeticPreDecrementRuleTest.php index 2bb021a9..232cf765 100644 --- a/tests/Rules/Operators/OperandInArithmeticPreDecrementRuleTest.php +++ b/tests/Rules/Operators/OperandInArithmeticPreDecrementRuleTest.php @@ -44,4 +44,17 @@ protected function getExpectedErrors(): array ]; } + /** + * {@inheritdoc} + */ + protected function getExpectedErrorsWithBcMath(): array + { + return [ + [ + 'Only numeric types are allowed in pre-decrement, BcMath\Number given.', + 16, + ], + ]; + } + } diff --git a/tests/Rules/Operators/OperandInArithmeticPreIncrementRuleTest.php b/tests/Rules/Operators/OperandInArithmeticPreIncrementRuleTest.php index 2ffe1bb6..662d2d50 100644 --- a/tests/Rules/Operators/OperandInArithmeticPreIncrementRuleTest.php +++ b/tests/Rules/Operators/OperandInArithmeticPreIncrementRuleTest.php @@ -40,4 +40,17 @@ protected function getExpectedErrors(): array ]; } + /** + * {@inheritdoc} + */ + protected function getExpectedErrorsWithBcMath(): array + { + return [ + [ + 'Only numeric types are allowed in pre-increment, BcMath\Number given.', + 20, + ], + ]; + } + } diff --git a/tests/Rules/Operators/OperandInArithmeticUnaryMinusRuleTest.php b/tests/Rules/Operators/OperandInArithmeticUnaryMinusRuleTest.php index d202bdbc..73005eab 100644 --- a/tests/Rules/Operators/OperandInArithmeticUnaryMinusRuleTest.php +++ b/tests/Rules/Operators/OperandInArithmeticUnaryMinusRuleTest.php @@ -31,4 +31,12 @@ public function testRule(): void ]); } + /** + * @requires PHP >= 8.4 + */ + public function testRuleWithBcMath(): void + { + $this->analyse([__DIR__ . '/data/operators-bcmath.php'], []); + } + } diff --git a/tests/Rules/Operators/OperandInArithmeticUnaryPlusRuleTest.php b/tests/Rules/Operators/OperandInArithmeticUnaryPlusRuleTest.php index 6cc253a3..55318a64 100644 --- a/tests/Rules/Operators/OperandInArithmeticUnaryPlusRuleTest.php +++ b/tests/Rules/Operators/OperandInArithmeticUnaryPlusRuleTest.php @@ -31,4 +31,12 @@ public function testRule(): void ]); } + /** + * @requires PHP >= 8.4 + */ + public function testRuleWithBcMath(): void + { + $this->analyse([__DIR__ . '/data/operators-bcmath.php'], []); + } + } diff --git a/tests/Rules/Operators/OperandsInArithmeticAdditionRuleTest.php b/tests/Rules/Operators/OperandsInArithmeticAdditionRuleTest.php index cc533050..01279682 100644 --- a/tests/Rules/Operators/OperandsInArithmeticAdditionRuleTest.php +++ b/tests/Rules/Operators/OperandsInArithmeticAdditionRuleTest.php @@ -60,4 +60,25 @@ public function testRule(): void $this->analyse([__DIR__ . '/data/operators.php'], $messages); } + /** + * @requires PHP >= 8.4 + */ + public function testRuleWithBcMath(): void + { + $this->analyse([__DIR__ . '/data/operators-bcmath.php'], [ + [ + 'Only numeric types are allowed in +, null given on the right side.', + 36, + ], + [ + 'Only numeric types are allowed in +, null given on the left side.', + 37, + ], + [ + 'Only numeric types are allowed in +, null given on the right side.', + 157, + ], + ]); + } + } diff --git a/tests/Rules/Operators/OperandsInArithmeticDivisionRuleTest.php b/tests/Rules/Operators/OperandsInArithmeticDivisionRuleTest.php index 57148083..229d7376 100644 --- a/tests/Rules/Operators/OperandsInArithmeticDivisionRuleTest.php +++ b/tests/Rules/Operators/OperandsInArithmeticDivisionRuleTest.php @@ -43,4 +43,25 @@ public function testRule(): void ]); } + /** + * @requires PHP >= 8.4 + */ + public function testRuleWithBcMath(): void + { + $this->analyse([__DIR__ . '/data/operators-bcmath.php'], [ + [ + 'Only numeric types are allowed in /, null given on the right side.', + 96, + ], + [ + 'Only numeric types are allowed in /, null given on the left side.', + 97, + ], + [ + 'Only numeric types are allowed in /, null given on the right side.', + 217, + ], + ]); + } + } diff --git a/tests/Rules/Operators/OperandsInArithmeticExponentiationRuleTest.php b/tests/Rules/Operators/OperandsInArithmeticExponentiationRuleTest.php index 539a969c..f24a0ed2 100644 --- a/tests/Rules/Operators/OperandsInArithmeticExponentiationRuleTest.php +++ b/tests/Rules/Operators/OperandsInArithmeticExponentiationRuleTest.php @@ -43,4 +43,25 @@ public function testRule(): void ]); } + /** + * @requires PHP >= 8.4 + */ + public function testRuleWithBcMath(): void + { + $this->analyse([__DIR__ . '/data/operators-bcmath.php'], [ + [ + 'Only numeric types are allowed in **, null given on the right side.', + 116, + ], + [ + 'Only numeric types are allowed in **, null given on the left side.', + 117, + ], + [ + 'Only numeric types are allowed in **, null given on the right side.', + 237, + ], + ]); + } + } diff --git a/tests/Rules/Operators/OperandsInArithmeticModuloRuleTest.php b/tests/Rules/Operators/OperandsInArithmeticModuloRuleTest.php index 54ccc48a..c833098c 100644 --- a/tests/Rules/Operators/OperandsInArithmeticModuloRuleTest.php +++ b/tests/Rules/Operators/OperandsInArithmeticModuloRuleTest.php @@ -43,4 +43,25 @@ public function testRule(): void ]); } + /** + * @requires PHP >= 8.4 + */ + public function testRuleWithBcMath(): void + { + $this->analyse([__DIR__ . '/data/operators-bcmath.php'], [ + [ + 'Only numeric types are allowed in %, null given on the right side.', + 136, + ], + [ + 'Only numeric types are allowed in %, null given on the left side.', + 137, + ], + [ + 'Only numeric types are allowed in %, null given on the right side.', + 257, + ], + ]); + } + } diff --git a/tests/Rules/Operators/OperandsInArithmeticMultiplicationRuleTest.php b/tests/Rules/Operators/OperandsInArithmeticMultiplicationRuleTest.php index 48641201..e5f4a197 100644 --- a/tests/Rules/Operators/OperandsInArithmeticMultiplicationRuleTest.php +++ b/tests/Rules/Operators/OperandsInArithmeticMultiplicationRuleTest.php @@ -43,4 +43,25 @@ public function testRule(): void ]); } + /** + * @requires PHP >= 8.4 + */ + public function testRuleWithBcMath(): void + { + $this->analyse([__DIR__ . '/data/operators-bcmath.php'], [ + [ + 'Only numeric types are allowed in *, null given on the right side.', + 76, + ], + [ + 'Only numeric types are allowed in *, null given on the left side.', + 77, + ], + [ + 'Only numeric types are allowed in *, null given on the right side.', + 197, + ], + ]); + } + } diff --git a/tests/Rules/Operators/OperandsInArithmeticSubtractionRuleTest.php b/tests/Rules/Operators/OperandsInArithmeticSubtractionRuleTest.php index 66dc3b09..f9338a54 100644 --- a/tests/Rules/Operators/OperandsInArithmeticSubtractionRuleTest.php +++ b/tests/Rules/Operators/OperandsInArithmeticSubtractionRuleTest.php @@ -43,4 +43,25 @@ public function testRule(): void ]); } + /** + * @requires PHP >= 8.4 + */ + public function testRuleWithBcMath(): void + { + $this->analyse([__DIR__ . '/data/operators-bcmath.php'], [ + [ + 'Only numeric types are allowed in -, null given on the right side.', + 56, + ], + [ + 'Only numeric types are allowed in -, null given on the left side.', + 57, + ], + [ + 'Only numeric types are allowed in -, null given on the right side.', + 177, + ], + ]); + } + } diff --git a/tests/Rules/Operators/data/increment-decrement-bcmath.php b/tests/Rules/Operators/data/increment-decrement-bcmath.php new file mode 100644 index 00000000..55615e78 --- /dev/null +++ b/tests/Rules/Operators/data/increment-decrement-bcmath.php @@ -0,0 +1,21 @@ + Date: Tue, 24 Feb 2026 14:31:33 +0200 Subject: [PATCH 2/2] Allow BcMath\Number increment/decrement --- src/Rules/Operators/OperatorRuleHelper.php | 15 +++++++++++++-- ...ArithmeticIncrementOrDecrementRuleTestCase.php | 2 ++ .../OperandInArithmeticPostDecrementRuleTest.php | 7 +------ .../OperandInArithmeticPostIncrementRuleTest.php | 7 +------ .../OperandInArithmeticPreDecrementRuleTest.php | 7 +------ .../OperandInArithmeticPreIncrementRuleTest.php | 7 +------ .../OperandInArithmeticUnaryMinusRuleTest.php | 2 ++ .../OperandInArithmeticUnaryPlusRuleTest.php | 2 ++ .../OperandsInArithmeticAdditionRuleTest.php | 2 ++ .../OperandsInArithmeticDivisionRuleTest.php | 2 ++ ...OperandsInArithmeticExponentiationRuleTest.php | 2 ++ .../OperandsInArithmeticModuloRuleTest.php | 2 ++ ...OperandsInArithmeticMultiplicationRuleTest.php | 2 ++ .../OperandsInArithmeticSubtractionRuleTest.php | 2 ++ 14 files changed, 35 insertions(+), 26 deletions(-) diff --git a/src/Rules/Operators/OperatorRuleHelper.php b/src/Rules/Operators/OperatorRuleHelper.php index 6de54cab..646f8acc 100644 --- a/src/Rules/Operators/OperatorRuleHelper.php +++ b/src/Rules/Operators/OperatorRuleHelper.php @@ -4,6 +4,7 @@ use PhpParser\Node\Expr; use PHPStan\Analyser\Scope; +use PHPStan\Php\PhpVersion; use PHPStan\Rules\RuleLevelHelper; use PHPStan\Type\Accessory\AccessoryNumericStringType; use PHPStan\Type\BenevolentUnionType; @@ -12,6 +13,7 @@ use PHPStan\Type\IntegerType; use PHPStan\Type\IntersectionType; use PHPStan\Type\MixedType; +use PHPStan\Type\ObjectType; use PHPStan\Type\StringType; use PHPStan\Type\Type; use PHPStan\Type\UnionType; @@ -21,9 +23,12 @@ class OperatorRuleHelper private RuleLevelHelper $ruleLevelHelper; - public function __construct(RuleLevelHelper $ruleLevelHelper) + private PhpVersion $phpVersion; + + public function __construct(RuleLevelHelper $ruleLevelHelper, PhpVersion $phpVersion) { $this->ruleLevelHelper = $ruleLevelHelper; + $this->phpVersion = $phpVersion; } public function isValidForArithmeticOperation(Scope $scope, Expr $expr): bool @@ -68,7 +73,13 @@ public function isValidForDecrement(Scope $scope, Expr $expr): bool private function isSubtypeOfNumber(Scope $scope, Expr $expr): bool { - $acceptedType = new UnionType([new IntegerType(), new FloatType(), new IntersectionType([new StringType(), new AccessoryNumericStringType()])]); + $acceptedTypes = [new IntegerType(), new FloatType(), new IntersectionType([new StringType(), new AccessoryNumericStringType()])]; + + if ($this->phpVersion->supportsBcMathNumberOperatorOverloading()) { + $acceptedTypes[] = new ObjectType('BcMath\Number'); + } + + $acceptedType = new UnionType($acceptedTypes); $type = $this->ruleLevelHelper->findTypeToCheck( $scope, diff --git a/tests/Rules/Operators/OperandInArithmeticIncrementOrDecrementRuleTestCase.php b/tests/Rules/Operators/OperandInArithmeticIncrementOrDecrementRuleTestCase.php index 9571a62e..0877b941 100644 --- a/tests/Rules/Operators/OperandInArithmeticIncrementOrDecrementRuleTestCase.php +++ b/tests/Rules/Operators/OperandInArithmeticIncrementOrDecrementRuleTestCase.php @@ -2,6 +2,7 @@ namespace PHPStan\Rules\Operators; +use PHPStan\Php\PhpVersion; use PHPStan\Rules\Rule; use PHPStan\Rules\RuleLevelHelper; use PHPStan\Testing\RuleTestCase; @@ -18,6 +19,7 @@ protected function getRule(): Rule return $this->createRule( new OperatorRuleHelper( self::getContainer()->getByType(RuleLevelHelper::class), + self::getContainer()->getByType(PhpVersion::class), ), ); } diff --git a/tests/Rules/Operators/OperandInArithmeticPostDecrementRuleTest.php b/tests/Rules/Operators/OperandInArithmeticPostDecrementRuleTest.php index 67a1e0a8..38697416 100644 --- a/tests/Rules/Operators/OperandInArithmeticPostDecrementRuleTest.php +++ b/tests/Rules/Operators/OperandInArithmeticPostDecrementRuleTest.php @@ -49,12 +49,7 @@ protected function getExpectedErrors(): array */ protected function getExpectedErrorsWithBcMath(): array { - return [ - [ - 'Only numeric types are allowed in post-decrement, BcMath\Number given.', - 8, - ], - ]; + return []; } } diff --git a/tests/Rules/Operators/OperandInArithmeticPostIncrementRuleTest.php b/tests/Rules/Operators/OperandInArithmeticPostIncrementRuleTest.php index 1548980c..353e4b78 100644 --- a/tests/Rules/Operators/OperandInArithmeticPostIncrementRuleTest.php +++ b/tests/Rules/Operators/OperandInArithmeticPostIncrementRuleTest.php @@ -45,12 +45,7 @@ protected function getExpectedErrors(): array */ protected function getExpectedErrorsWithBcMath(): array { - return [ - [ - 'Only numeric types are allowed in post-increment, BcMath\Number given.', - 12, - ], - ]; + return []; } } diff --git a/tests/Rules/Operators/OperandInArithmeticPreDecrementRuleTest.php b/tests/Rules/Operators/OperandInArithmeticPreDecrementRuleTest.php index 232cf765..d629c8ea 100644 --- a/tests/Rules/Operators/OperandInArithmeticPreDecrementRuleTest.php +++ b/tests/Rules/Operators/OperandInArithmeticPreDecrementRuleTest.php @@ -49,12 +49,7 @@ protected function getExpectedErrors(): array */ protected function getExpectedErrorsWithBcMath(): array { - return [ - [ - 'Only numeric types are allowed in pre-decrement, BcMath\Number given.', - 16, - ], - ]; + return []; } } diff --git a/tests/Rules/Operators/OperandInArithmeticPreIncrementRuleTest.php b/tests/Rules/Operators/OperandInArithmeticPreIncrementRuleTest.php index 662d2d50..a6a855b2 100644 --- a/tests/Rules/Operators/OperandInArithmeticPreIncrementRuleTest.php +++ b/tests/Rules/Operators/OperandInArithmeticPreIncrementRuleTest.php @@ -45,12 +45,7 @@ protected function getExpectedErrors(): array */ protected function getExpectedErrorsWithBcMath(): array { - return [ - [ - 'Only numeric types are allowed in pre-increment, BcMath\Number given.', - 20, - ], - ]; + return []; } } diff --git a/tests/Rules/Operators/OperandInArithmeticUnaryMinusRuleTest.php b/tests/Rules/Operators/OperandInArithmeticUnaryMinusRuleTest.php index 73005eab..fbd3964f 100644 --- a/tests/Rules/Operators/OperandInArithmeticUnaryMinusRuleTest.php +++ b/tests/Rules/Operators/OperandInArithmeticUnaryMinusRuleTest.php @@ -2,6 +2,7 @@ namespace PHPStan\Rules\Operators; +use PHPStan\Php\PhpVersion; use PHPStan\Rules\Rule; use PHPStan\Rules\RuleLevelHelper; use PHPStan\Testing\RuleTestCase; @@ -17,6 +18,7 @@ protected function getRule(): Rule return new OperandInArithmeticUnaryMinusRule( new OperatorRuleHelper( self::getContainer()->getByType(RuleLevelHelper::class), + self::getContainer()->getByType(PhpVersion::class), ), ); } diff --git a/tests/Rules/Operators/OperandInArithmeticUnaryPlusRuleTest.php b/tests/Rules/Operators/OperandInArithmeticUnaryPlusRuleTest.php index 55318a64..2a961f37 100644 --- a/tests/Rules/Operators/OperandInArithmeticUnaryPlusRuleTest.php +++ b/tests/Rules/Operators/OperandInArithmeticUnaryPlusRuleTest.php @@ -2,6 +2,7 @@ namespace PHPStan\Rules\Operators; +use PHPStan\Php\PhpVersion; use PHPStan\Rules\Rule; use PHPStan\Rules\RuleLevelHelper; use PHPStan\Testing\RuleTestCase; @@ -17,6 +18,7 @@ protected function getRule(): Rule return new OperandInArithmeticUnaryPlusRule( new OperatorRuleHelper( self::getContainer()->getByType(RuleLevelHelper::class), + self::getContainer()->getByType(PhpVersion::class), ), ); } diff --git a/tests/Rules/Operators/OperandsInArithmeticAdditionRuleTest.php b/tests/Rules/Operators/OperandsInArithmeticAdditionRuleTest.php index 01279682..568056d8 100644 --- a/tests/Rules/Operators/OperandsInArithmeticAdditionRuleTest.php +++ b/tests/Rules/Operators/OperandsInArithmeticAdditionRuleTest.php @@ -2,6 +2,7 @@ namespace PHPStan\Rules\Operators; +use PHPStan\Php\PhpVersion; use PHPStan\Rules\Rule; use PHPStan\Rules\RuleLevelHelper; use PHPStan\Testing\RuleTestCase; @@ -19,6 +20,7 @@ protected function getRule(): Rule return new OperandsInArithmeticAdditionRule( new OperatorRuleHelper( self::getContainer()->getByType(RuleLevelHelper::class), + self::getContainer()->getByType(PhpVersion::class), ), ); } diff --git a/tests/Rules/Operators/OperandsInArithmeticDivisionRuleTest.php b/tests/Rules/Operators/OperandsInArithmeticDivisionRuleTest.php index 229d7376..e5ca2550 100644 --- a/tests/Rules/Operators/OperandsInArithmeticDivisionRuleTest.php +++ b/tests/Rules/Operators/OperandsInArithmeticDivisionRuleTest.php @@ -2,6 +2,7 @@ namespace PHPStan\Rules\Operators; +use PHPStan\Php\PhpVersion; use PHPStan\Rules\Rule; use PHPStan\Rules\RuleLevelHelper; use PHPStan\Testing\RuleTestCase; @@ -17,6 +18,7 @@ protected function getRule(): Rule return new OperandsInArithmeticDivisionRule( new OperatorRuleHelper( self::getContainer()->getByType(RuleLevelHelper::class), + self::getContainer()->getByType(PhpVersion::class), ), ); } diff --git a/tests/Rules/Operators/OperandsInArithmeticExponentiationRuleTest.php b/tests/Rules/Operators/OperandsInArithmeticExponentiationRuleTest.php index f24a0ed2..97ac2e8d 100644 --- a/tests/Rules/Operators/OperandsInArithmeticExponentiationRuleTest.php +++ b/tests/Rules/Operators/OperandsInArithmeticExponentiationRuleTest.php @@ -2,6 +2,7 @@ namespace PHPStan\Rules\Operators; +use PHPStan\Php\PhpVersion; use PHPStan\Rules\Rule; use PHPStan\Rules\RuleLevelHelper; use PHPStan\Testing\RuleTestCase; @@ -17,6 +18,7 @@ protected function getRule(): Rule return new OperandsInArithmeticExponentiationRule( new OperatorRuleHelper( self::getContainer()->getByType(RuleLevelHelper::class), + self::getContainer()->getByType(PhpVersion::class), ), ); } diff --git a/tests/Rules/Operators/OperandsInArithmeticModuloRuleTest.php b/tests/Rules/Operators/OperandsInArithmeticModuloRuleTest.php index c833098c..69ff35ca 100644 --- a/tests/Rules/Operators/OperandsInArithmeticModuloRuleTest.php +++ b/tests/Rules/Operators/OperandsInArithmeticModuloRuleTest.php @@ -2,6 +2,7 @@ namespace PHPStan\Rules\Operators; +use PHPStan\Php\PhpVersion; use PHPStan\Rules\Rule; use PHPStan\Rules\RuleLevelHelper; use PHPStan\Testing\RuleTestCase; @@ -17,6 +18,7 @@ protected function getRule(): Rule return new OperandsInArithmeticModuloRule( new OperatorRuleHelper( self::getContainer()->getByType(RuleLevelHelper::class), + self::getContainer()->getByType(PhpVersion::class), ), ); } diff --git a/tests/Rules/Operators/OperandsInArithmeticMultiplicationRuleTest.php b/tests/Rules/Operators/OperandsInArithmeticMultiplicationRuleTest.php index e5f4a197..89725ef5 100644 --- a/tests/Rules/Operators/OperandsInArithmeticMultiplicationRuleTest.php +++ b/tests/Rules/Operators/OperandsInArithmeticMultiplicationRuleTest.php @@ -2,6 +2,7 @@ namespace PHPStan\Rules\Operators; +use PHPStan\Php\PhpVersion; use PHPStan\Rules\Rule; use PHPStan\Rules\RuleLevelHelper; use PHPStan\Testing\RuleTestCase; @@ -17,6 +18,7 @@ protected function getRule(): Rule return new OperandsInArithmeticMultiplicationRule( new OperatorRuleHelper( self::getContainer()->getByType(RuleLevelHelper::class), + self::getContainer()->getByType(PhpVersion::class), ), ); } diff --git a/tests/Rules/Operators/OperandsInArithmeticSubtractionRuleTest.php b/tests/Rules/Operators/OperandsInArithmeticSubtractionRuleTest.php index f9338a54..8539b8e5 100644 --- a/tests/Rules/Operators/OperandsInArithmeticSubtractionRuleTest.php +++ b/tests/Rules/Operators/OperandsInArithmeticSubtractionRuleTest.php @@ -2,6 +2,7 @@ namespace PHPStan\Rules\Operators; +use PHPStan\Php\PhpVersion; use PHPStan\Rules\Rule; use PHPStan\Rules\RuleLevelHelper; use PHPStan\Testing\RuleTestCase; @@ -17,6 +18,7 @@ protected function getRule(): Rule return new OperandsInArithmeticSubtractionRule( new OperatorRuleHelper( self::getContainer()->getByType(RuleLevelHelper::class), + self::getContainer()->getByType(PhpVersion::class), ), ); }