diff --git a/rules/CodeQuality/General/AddErrorCodeToExceptionRector.php b/rules/CodeQuality/General/AddErrorCodeToExceptionRector.php index 68344cb93..314b79cf5 100644 --- a/rules/CodeQuality/General/AddErrorCodeToExceptionRector.php +++ b/rules/CodeQuality/General/AddErrorCodeToExceptionRector.php @@ -68,6 +68,6 @@ private function shouldSkip(Throw_ $node): bool return true; } - return count($node->expr->args) > 1; + return count($node->expr->args) !== 1; } } diff --git a/tests/Rector/CodeQuality/General/AddErrorCodeToExceptionRector/Fixture/fixture.php.inc b/tests/Rector/CodeQuality/General/AddErrorCodeToExceptionRector/Fixture/fixture.php.inc index bf838a2f4..f8368526e 100644 --- a/tests/Rector/CodeQuality/General/AddErrorCodeToExceptionRector/Fixture/fixture.php.inc +++ b/tests/Rector/CodeQuality/General/AddErrorCodeToExceptionRector/Fixture/fixture.php.inc @@ -6,6 +6,10 @@ if ('a' === 'b') { throw new \RuntimeException('my message'); } +if ('b' === 'c') { + throw new \RuntimeException(); +} + throw new \RuntimeException('do not touch this', 564); ?> ----- @@ -17,5 +21,9 @@ if ('a' === 'b') { throw new \RuntimeException('my message', 1729021897); } +if ('b' === 'c') { + throw new \RuntimeException(); +} + throw new \RuntimeException('do not touch this', 564); ?>