mirror of
https://github.com/rectorphp/rector.git
synced 2025-01-17 05:18:18 +01:00
Updated Rector to commit 69c22013f6d127aca89b2c18070a4e27119d94bf
69c22013f6
Rollback SimpleCallableNodeTraverser usage on ByRefReturnNodeVisitor (#6624)
This commit is contained in:
parent
f61a8361f2
commit
b15d939f9f
@ -19,12 +19,12 @@ final class VersionResolver
|
||||
* @api
|
||||
* @var string
|
||||
*/
|
||||
public const PACKAGE_VERSION = 'df255c0db4dbfce78ad3fc5bbdb9997490c2ec6d';
|
||||
public const PACKAGE_VERSION = '69c22013f6d127aca89b2c18070a4e27119d94bf';
|
||||
/**
|
||||
* @api
|
||||
* @var string
|
||||
*/
|
||||
public const RELEASE_DATE = '2024-12-20 14:23:58';
|
||||
public const RELEASE_DATE = '2024-12-20 14:29:40';
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
|
@ -5,15 +5,23 @@ namespace Rector\NodeTypeResolver\PHPStan\Scope\NodeVisitor;
|
||||
|
||||
use PhpParser\Node;
|
||||
use PhpParser\Node\FunctionLike;
|
||||
use PhpParser\Node\Stmt;
|
||||
use PhpParser\Node\Stmt\Class_;
|
||||
use PhpParser\Node\Stmt\Return_;
|
||||
use PhpParser\Node\Stmt\Switch_;
|
||||
use PhpParser\NodeVisitor;
|
||||
use PhpParser\NodeVisitorAbstract;
|
||||
use Rector\Contract\PhpParser\Node\StmtsAwareInterface;
|
||||
use Rector\NodeTypeResolver\Node\AttributeKey;
|
||||
use Rector\NodeTypeResolver\PHPStan\Scope\Contract\NodeVisitor\ScopeResolverNodeVisitorInterface;
|
||||
use Rector\PhpDocParser\NodeTraverser\SimpleCallableNodeTraverser;
|
||||
final class ByRefReturnNodeVisitor extends NodeVisitorAbstract implements ScopeResolverNodeVisitorInterface
|
||||
{
|
||||
/**
|
||||
* @readonly
|
||||
*/
|
||||
private SimpleCallableNodeTraverser $simpleCallableNodeTraverser;
|
||||
public function __construct(SimpleCallableNodeTraverser $simpleCallableNodeTraverser)
|
||||
{
|
||||
$this->simpleCallableNodeTraverser = $simpleCallableNodeTraverser;
|
||||
}
|
||||
public function enterNode(Node $node) : ?Node
|
||||
{
|
||||
if (!$node instanceof FunctionLike) {
|
||||
@ -26,31 +34,16 @@ final class ByRefReturnNodeVisitor extends NodeVisitorAbstract implements ScopeR
|
||||
if ($stmts === null) {
|
||||
return null;
|
||||
}
|
||||
$this->setByRefAttribute($stmts);
|
||||
$this->simpleCallableNodeTraverser->traverseNodesWithCallable($stmts, static function (Node $node) {
|
||||
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;
|
||||
});
|
||||
return null;
|
||||
}
|
||||
/**
|
||||
* @param Stmt[] $stmts
|
||||
*/
|
||||
private function setByRefAttribute(array $stmts) : void
|
||||
{
|
||||
foreach ($stmts as $stmt) {
|
||||
if ($stmt instanceof FunctionLike) {
|
||||
continue;
|
||||
}
|
||||
if ($stmt instanceof StmtsAwareInterface && $stmt->stmts !== null) {
|
||||
$this->setByRefAttribute($stmt->stmts);
|
||||
continue;
|
||||
}
|
||||
if ($stmt instanceof Switch_) {
|
||||
foreach ($stmt->cases as $case) {
|
||||
$this->setByRefAttribute($case->stmts);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
if ($stmt instanceof Return_) {
|
||||
$stmt->setAttribute(AttributeKey::IS_BYREF_RETURN, \true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user