From cb8a63ca314696c70ed8522b98e1831fb58f287f Mon Sep 17 00:00:00 2001 From: Tomas Votruba Date: Sat, 2 Dec 2023 04:51:32 +0000 Subject: [PATCH] Updated Rector to commit 71c22e20d9a3b2ba187515711b13fca40b595d93 https://github.com/rectorphp/rector-src/commit/71c22e20d9a3b2ba187515711b13fca40b595d93 [CodeQuality] Skip with else on SimplifyForeachToCoalescingRector (#5307) --- .../Rector/Foreach_/SimplifyForeachToCoalescingRector.php | 4 ++++ src/Application/VersionResolver.php | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) 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 */