From 3248417c831cc7953aac105440f82e4aaea17edf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20M=C3=BCller?= <1005065+DeepDiver1975@users.noreply.github.com> Date: Mon, 22 Feb 2021 13:55:18 +0100 Subject: [PATCH] Do not increment max integer value (fixes #1484) (#1486) --- src/Mutator/Number/IncrementInteger.php | 5 +++++ .../Mutator/Number/IncrementIntegerTest.php | 14 ++++++++++++++ 2 files changed, 19 insertions(+) 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' +