From f8a188b5f430b529cce8d481bceb05be49c91d52 Mon Sep 17 00:00:00 2001 From: Rudolph Gottesheim Date: Mon, 18 May 2026 14:32:57 +0200 Subject: [PATCH] Allow the if-true-return-false pattern MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PHP CS Fixer's `simplified_if_return` produced malformed output (trailing semicolons on their own line, gratuitous `(bool)` casts, extra wrapping parens). Both that rule and its Slevomat counterpart `UselessIfConditionWithReturn` are now disabled, and the fixture moves from invalid to valid with a comment explaining why the pattern is useful — it keeps multiple boolean-returning if-branches visually consistent. Co-Authored-By: Claude Opus 4.7 (1M context) --- Eventjet/ruleset.xml | 3 --- php-cs-fixer-rules.php | 1 - .../invalid/useless-if-with-return.php | 11 ---------- .../fixtures/valid/useless-if-with-return.php | 22 +++++++++++++++++++ 4 files changed, 22 insertions(+), 15 deletions(-) delete mode 100644 tests/fixtures/invalid/useless-if-with-return.php create mode 100644 tests/fixtures/valid/useless-if-with-return.php diff --git a/Eventjet/ruleset.xml b/Eventjet/ruleset.xml index ca4b4aa..af435fb 100644 --- a/Eventjet/ruleset.xml +++ b/Eventjet/ruleset.xml @@ -265,9 +265,6 @@ - - - diff --git a/php-cs-fixer-rules.php b/php-cs-fixer-rules.php index 8ed1b35..d6bb3f4 100644 --- a/php-cs-fixer-rules.php +++ b/php-cs-fixer-rules.php @@ -121,7 +121,6 @@ 'phpdoc_var_annotation_correct_order' => false, 'php_unit_data_provider_static' => true, 'self_accessor' => true, - 'simplified_if_return' => true, 'single_quote' => true, 'single_space_around_construct' => true, // Loose comparison is lint territory — PHPStan and Psalm both flag it. Kept diff --git a/tests/fixtures/invalid/useless-if-with-return.php b/tests/fixtures/invalid/useless-if-with-return.php deleted file mode 100644 index e4ba109..0000000 --- a/tests/fixtures/invalid/useless-if-with-return.php +++ /dev/null @@ -1,11 +0,0 @@ - 0) { - return true; - } - return false; -} diff --git a/tests/fixtures/valid/useless-if-with-return.php b/tests/fixtures/valid/useless-if-with-return.php new file mode 100644 index 0000000..61db86d --- /dev/null +++ b/tests/fixtures/valid/useless-if-with-return.php @@ -0,0 +1,22 @@ + 0) { + return true; + } + return false; +}