From d9834a6d6976e13a983a9d92de780e12678ddc66 Mon Sep 17 00:00:00 2001 From: Tomas Votruba Date: Sun, 3 Dec 2023 20:12:56 +0000 Subject: [PATCH] Updated Rector to commit 8e6d46a58fff8e6bd5276b9ae473bfb91460b487 https://github.com/rectorphp/rector-src/commit/8e6d46a58fff8e6bd5276b9ae473bfb91460b487 [Instanceof] Fix combination of dead instance and compare (#5319) --- rules/DeadCode/Rector/If_/RemoveDeadInstanceOfRector.php | 6 ++++++ src/Application/VersionResolver.php | 4 ++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/rules/DeadCode/Rector/If_/RemoveDeadInstanceOfRector.php b/rules/DeadCode/Rector/If_/RemoveDeadInstanceOfRector.php index 67231692cf5..145caa986f6 100644 --- a/rules/DeadCode/Rector/If_/RemoveDeadInstanceOfRector.php +++ b/rules/DeadCode/Rector/If_/RemoveDeadInstanceOfRector.php @@ -3,6 +3,8 @@ declare (strict_types=1); namespace Rector\DeadCode\Rector\If_; +use PhpParser\Node\Expr\Assign; +use PhpParser\Node\Stmt\Expression; use PhpParser\Node; use PhpParser\Node\Expr; use PhpParser\Node\Expr\BooleanNot; @@ -98,6 +100,10 @@ CODE_SAMPLE if ($this->shouldSkipFromNotTypedParam($instanceof)) { return null; } + if ($instanceof->expr instanceof Assign) { + $assignExpression = new Expression($instanceof->expr); + return \array_merge([$assignExpression], $if->stmts); + } if ($if->cond !== $instanceof) { return NodeTraverser::REMOVE_NODE; } diff --git a/src/Application/VersionResolver.php b/src/Application/VersionResolver.php index 992980d98c5..6585149445f 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 = '026398c9e1078cb3ac5cac41767b620872166859'; + public const PACKAGE_VERSION = '8e6d46a58fff8e6bd5276b9ae473bfb91460b487'; /** * @api * @var string */ - public const RELEASE_DATE = '2023-12-03 20:08:03'; + public const RELEASE_DATE = '2023-12-03 20:10:35'; /** * @var int */