diff --git a/rules/CodeQuality/Rector/FunctionLike/SimplifyUselessVariableRector.php b/rules/CodeQuality/Rector/FunctionLike/SimplifyUselessVariableRector.php index 62cf7e577e1..663ae07978d 100644 --- a/rules/CodeQuality/Rector/FunctionLike/SimplifyUselessVariableRector.php +++ b/rules/CodeQuality/Rector/FunctionLike/SimplifyUselessVariableRector.php @@ -123,7 +123,7 @@ private function shouldSkipStmt(Return_ $return, Stmt $previousStmt): bool return true; } - if ($return->getAttribute(AttributeKey::IS_BYREF_RETURN) === true) { + if ($return->getAttribute(AttributeKey::IS_INSIDE_BYREF_FUNCTION_LIKE) === true) { return true; } diff --git a/src/NodeTypeResolver/Node/AttributeKey.php b/src/NodeTypeResolver/Node/AttributeKey.php index a8d933970b0..c65de9ebb2b 100644 --- a/src/NodeTypeResolver/Node/AttributeKey.php +++ b/src/NodeTypeResolver/Node/AttributeKey.php @@ -93,8 +93,6 @@ final class AttributeKey public const string IS_BYREF_VAR = 'is_byref_var'; - public const string IS_BYREF_RETURN = 'is_byref_return'; - public const string IS_BEING_ASSIGNED = 'is_being_assigned'; public const string IS_ASSIGN_OP_VAR = 'is_assign_op_var'; diff --git a/src/PhpParser/NodeVisitor/ByRefNodeVisitor.php b/src/PhpParser/NodeVisitor/ByRefNodeVisitor.php index dcec8419060..4074a1b7dca 100644 --- a/src/PhpParser/NodeVisitor/ByRefNodeVisitor.php +++ b/src/PhpParser/NodeVisitor/ByRefNodeVisitor.php @@ -10,9 +10,6 @@ use PhpParser\Node\Expr\Closure; use PhpParser\Node\Expr\Variable; use PhpParser\Node\FunctionLike; -use PhpParser\Node\Stmt\Class_; -use PhpParser\Node\Stmt\Return_; -use PhpParser\NodeVisitor; use PhpParser\NodeVisitorAbstract; use Rector\Contract\PhpParser\DecoratingNodeVisitorInterface; use Rector\NodeTypeResolver\Node\AttributeKey; @@ -20,7 +17,7 @@ use Rector\PhpParser\NodeTraverser\SimpleNodeTraverser; /** - * Marks by-ref returns (IS_BYREF_RETURN / IS_INSIDE_BYREF_FUNCTION_LIKE) and by-ref variables + * Marks by-ref returns IS_INSIDE_BYREF_FUNCTION_LIKE and by-ref variables * (IS_BYREF_VAR) from a single FunctionLike entry, sharing the one node subscription. */ final class ByRefNodeVisitor extends NodeVisitorAbstract implements DecoratingNodeVisitorInterface @@ -62,23 +59,6 @@ private function decorateByRefReturn(FunctionLike $functionLike, array $stmts): } SimpleNodeTraverser::decorateWithAttributeValue($stmts, AttributeKey::IS_INSIDE_BYREF_FUNCTION_LIKE, true); - - $this->simpleCallableNodeTraverser->traverseNodesWithCallable( - $stmts, - static function (Node $node): int|null|Node { - // avoid nested functions or classes - if ($node instanceof Class_ || $node instanceof FunctionLike) { - return NodeVisitor::DONT_TRAVERSE_CURRENT_AND_CHILDREN; - } - - if (! $node instanceof Return_) { - return null; - } - - $node->setAttribute(AttributeKey::IS_BYREF_RETURN, true); - return $node; - } - ); } /**