From cae06912ed7d7274d900fdc996448f100be2ed34 Mon Sep 17 00:00:00 2001 From: Abdul Malik Ikhsan Date: Sat, 23 Mar 2024 12:10:30 +0700 Subject: [PATCH] [CodeQuality] Skip do { } while always returned on ExplicitReturnNullRector (#5760) --- .../skip_do_while_always_returned.php.inc | 17 +++++++++++++++++ .../TypeInferer/SilentVoidResolver.php | 5 +++++ 2 files changed, 22 insertions(+) create mode 100644 rules-tests/CodeQuality/Rector/ClassMethod/ExplicitReturnNullRector/Fixture/skip_do_while_always_returned.php.inc diff --git a/rules-tests/CodeQuality/Rector/ClassMethod/ExplicitReturnNullRector/Fixture/skip_do_while_always_returned.php.inc b/rules-tests/CodeQuality/Rector/ClassMethod/ExplicitReturnNullRector/Fixture/skip_do_while_always_returned.php.inc new file mode 100644 index 00000000000..78efe8c22ea --- /dev/null +++ b/rules-tests/CodeQuality/Rector/ClassMethod/ExplicitReturnNullRector/Fixture/skip_do_while_always_returned.php.inc @@ -0,0 +1,17 @@ +isIfReturn($stmt)) { return true; } + + if ($stmt instanceof Do_ && $this->hasStmtsAlwaysReturnOrExit($stmt->stmts)) { + return true; + } } return false;