diff --git a/rules/DeadCode/Rector/If_/RemoveDeadInstanceOfRector.php b/rules/DeadCode/Rector/If_/RemoveDeadInstanceOfRector.php index 67231692cf52..145caa986f64 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 @@ private function refactorStmtAndInstanceof(If_ $if, Instanceof_ $instanceof) 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 992980d98c56..6585149445f3 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 */