diff --git a/src/Rules/Operators/InvalidIncDecOperationRule.php b/src/Rules/Operators/InvalidIncDecOperationRule.php index 8c50854e7f..df766a668d 100644 --- a/src/Rules/Operators/InvalidIncDecOperationRule.php +++ b/src/Rules/Operators/InvalidIncDecOperationRule.php @@ -113,7 +113,7 @@ public function processNode(Node $node, Scope $scope): array $deprecatedString = true; } - $allowedTypes = [new FloatType(), new IntegerType(), $string, new ObjectType('SimpleXMLElement')]; + $allowedTypes = [new FloatType(), new IntegerType(), $string, new ObjectType('SimpleXMLElement'), new ObjectType('GMP')]; $deprecatedNull = false; if ( !$this->phpVersion->deprecatesDecOnNonNumericString() diff --git a/tests/PHPStan/Rules/Operators/InvalidIncDecOperationRuleTest.php b/tests/PHPStan/Rules/Operators/InvalidIncDecOperationRuleTest.php index 11e5981308..e7796e92f5 100644 --- a/tests/PHPStan/Rules/Operators/InvalidIncDecOperationRuleTest.php +++ b/tests/PHPStan/Rules/Operators/InvalidIncDecOperationRuleTest.php @@ -249,4 +249,9 @@ public function testBcMathNumber(): void $this->analyse([__DIR__ . '/data/inc-dec-bcmath-number.php'], []); } + public function testGmp(): void + { + $this->analyse([__DIR__ . '/data/inc-dec-gmp.php'], []); + } + } diff --git a/tests/PHPStan/Rules/Operators/data/inc-dec-gmp.php b/tests/PHPStan/Rules/Operators/data/inc-dec-gmp.php new file mode 100644 index 0000000000..2cd5362142 --- /dev/null +++ b/tests/PHPStan/Rules/Operators/data/inc-dec-gmp.php @@ -0,0 +1,21 @@ +