diff --git a/rules/CodeQuality/Rector/Foreach_/SimplifyForeachToCoalescingRector.php b/rules/CodeQuality/Rector/Foreach_/SimplifyForeachToCoalescingRector.php index f258373e3dd..637dc3a8361 100644 --- a/rules/CodeQuality/Rector/Foreach_/SimplifyForeachToCoalescingRector.php +++ b/rules/CodeQuality/Rector/Foreach_/SimplifyForeachToCoalescingRector.php @@ -10,6 +10,7 @@ use PhpParser\Node\Expr\Assign; use PhpParser\Node\Expr\BinaryOp\Coalesce; use PhpParser\Node\Expr\BinaryOp\Identical; use PhpParser\Node\Stmt; +use PhpParser\Node\Stmt\Else_; use PhpParser\Node\Stmt\Expression; use PhpParser\Node\Stmt\Foreach_; use PhpParser\Node\Stmt\If_; @@ -125,6 +126,9 @@ CODE_SAMPLE if (\count($if->stmts) !== 1) { return null; } + if ($if->else instanceof Else_ || $if->elseifs !== []) { + return null; + } $innerStmt = $if->stmts[0]; if ($innerStmt instanceof Return_) { return $innerStmt; diff --git a/src/Application/VersionResolver.php b/src/Application/VersionResolver.php index f88d62903be..e200fe5ca4d 100644 --- a/src/Application/VersionResolver.php +++ b/src/Application/VersionResolver.php @@ -19,12 +19,12 @@ final class VersionResolver * @api * @var string */ - public const PACKAGE_VERSION = '17397d5aecee91cdb525a1e1b012718a101cf4be'; + public const PACKAGE_VERSION = '71c22e20d9a3b2ba187515711b13fca40b595d93'; /** * @api * @var string */ - public const RELEASE_DATE = '2023-12-02 11:27:01'; + public const RELEASE_DATE = '2023-12-02 11:49:23'; /** * @var int */