diff --git a/src/Mutator/Number/IncrementInteger.php b/src/Mutator/Number/IncrementInteger.php index e2fba0804..e591c40b0 100644 --- a/src/Mutator/Number/IncrementInteger.php +++ b/src/Mutator/Number/IncrementInteger.php @@ -39,6 +39,7 @@ use Infection\Mutator\GetMutatorName; use Infection\Mutator\MutatorCategory; use Infection\PhpParser\Visitor\ParentConnector; +use const PHP_INT_MAX; use PhpParser\Node; /** @@ -87,6 +88,10 @@ public function canMutate(Node $node): bool return false; } + if ($node->value === PHP_INT_MAX) { + return false; + } + if ( $node->value === 0 && ($this->isPartOfComparison($node) || ParentConnector::getParent($node) instanceof Node\Expr\Assign) diff --git a/tests/phpunit/Mutator/Number/IncrementIntegerTest.php b/tests/phpunit/Mutator/Number/IncrementIntegerTest.php index 434ed30d3..0859b11e1 100644 --- a/tests/phpunit/Mutator/Number/IncrementIntegerTest.php +++ b/tests/phpunit/Mutator/Number/IncrementIntegerTest.php @@ -239,6 +239,20 @@ public function mutationsProvider(): iterable [ + <<<'PHP' +