diff --git a/rules/DeadCode/Rector/Assign/RemoveUnusedVariableAssignRector.php b/rules/DeadCode/Rector/Assign/RemoveUnusedVariableAssignRector.php index ffaefe89bf8..61ea27c1b9b 100644 --- a/rules/DeadCode/Rector/Assign/RemoveUnusedVariableAssignRector.php +++ b/rules/DeadCode/Rector/Assign/RemoveUnusedVariableAssignRector.php @@ -95,10 +95,7 @@ CODE_SAMPLE return null; } // we cannot be sure here - if ($this->containsCompactFuncCall($node)) { - return null; - } - if ($this->containsFileIncludes($node)) { + if ($this->shouldSkip($stmts)) { return null; } $assignedVariableNamesByStmtPosition = $this->resolvedAssignedVariablesByStmtPosition($stmts); @@ -165,24 +162,19 @@ CODE_SAMPLE return \false; } /** - * @param \PhpParser\Node\Stmt\ClassMethod|\PhpParser\Node\Stmt\Function_ $functionLike + * @param Stmt[] $stmts */ - private function containsCompactFuncCall($functionLike) : bool + private function shouldSkip(array $stmts) : bool { - $compactFuncCall = $this->betterNodeFinder->findFirst($functionLike, function (Node $node) : bool { + return (bool) $this->betterNodeFinder->findFirst($stmts, function (Node $node) : bool { + if ($node instanceof Include_) { + return \true; + } if (!$node instanceof FuncCall) { return \false; } return $this->isName($node, 'compact'); }); - return $compactFuncCall instanceof FuncCall; - } - /** - * @param \PhpParser\Node\Stmt\ClassMethod|\PhpParser\Node\Stmt\Function_ $functionLike - */ - private function containsFileIncludes($functionLike) : bool - { - return (bool) $this->betterNodeFinder->findInstancesOf($functionLike, [Include_::class]); } /** * @param array $stmts diff --git a/src/Application/VersionResolver.php b/src/Application/VersionResolver.php index 5d3be8df3f4..11fc354f1fa 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 = 'b523b734e052b47d756330e7deeaa68372fbd494'; + public const PACKAGE_VERSION = 'b4212ed99d3aadc3ce6371c984b644b54252752e'; /** * @api * @var string */ - public const RELEASE_DATE = '2024-03-04 03:44:29'; + public const RELEASE_DATE = '2024-03-04 21:00:48'; /** * @var int */