From 0348124a5535b99712da4debc136d2e73647b97a Mon Sep 17 00:00:00 2001 From: Abdul Malik Ikhsan Date: Wed, 3 Apr 2024 21:15:24 +0700 Subject: [PATCH] [CodeQuality] Skip Switch_ always returned on ExplicitReturnNullRector (#5800) * [CodeQuality] Skip Switch_ always returned on ExplicitReturnNullRector * [ci-review] Rector Rectify --------- Co-authored-by: GitHub Action --- .../Fixture/skip_switch_always_return.php.inc | 17 +++++++++++++++++ .../TypeInferer/SilentVoidResolver.php | 5 ++++- 2 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 rules-tests/CodeQuality/Rector/ClassMethod/ExplicitReturnNullRector/Fixture/skip_switch_always_return.php.inc diff --git a/rules-tests/CodeQuality/Rector/ClassMethod/ExplicitReturnNullRector/Fixture/skip_switch_always_return.php.inc b/rules-tests/CodeQuality/Rector/ClassMethod/ExplicitReturnNullRector/Fixture/skip_switch_always_return.php.inc new file mode 100644 index 00000000000..e7951bfc47a --- /dev/null +++ b/rules-tests/CodeQuality/Rector/ClassMethod/ExplicitReturnNullRector/Fixture/skip_switch_always_return.php.inc @@ -0,0 +1,17 @@ +resolveReturnOrExitCount($switch); + $cases = array_filter($switch->cases, static fn(Case_ $case): bool => $case->stmts !== []); + // has same amount of first return or exit nodes as switches - return count($switch->cases) === $casesWithReturnOrExitCount; + return count($cases) === $casesWithReturnOrExitCount; } private function isTryCatchAlwaysReturnOrExit(TryCatch $tryCatch): bool