From 0981ded66e36263d68293fcb6effb4cf8b93b70a Mon Sep 17 00:00:00 2001 From: Tomas Votruba Date: Thu, 22 Aug 2024 14:18:51 +0000 Subject: [PATCH] Updated Rector to commit 05f832313c704757b3ff3925f6c0da45b5fb3cc7 https://github.com/rectorphp/rector-src/commit/05f832313c704757b3ff3925f6c0da45b5fb3cc7 [AttributeKey] Drop statementDepth attribute (#6249) --- src/Application/VersionResolver.php | 4 +-- src/NodeTypeResolver/Node/AttributeKey.php | 4 --- .../Scope/NodeVisitor/StmtKeyNodeVisitor.php | 27 ------------------- 3 files changed, 2 insertions(+), 33 deletions(-) diff --git a/src/Application/VersionResolver.php b/src/Application/VersionResolver.php index 549157196ecc..8c578cf5e2cc 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 = 'e3ad355409775a85349aed5ba8e803b7a93fc4dc'; + public const PACKAGE_VERSION = '05f832313c704757b3ff3925f6c0da45b5fb3cc7'; /** * @api * @var string */ - public const RELEASE_DATE = '2024-08-22 13:30:44'; + public const RELEASE_DATE = '2024-08-22 21:16:19'; /** * @var int */ diff --git a/src/NodeTypeResolver/Node/AttributeKey.php b/src/NodeTypeResolver/Node/AttributeKey.php index 55d134b4006f..536a6cd38cb8 100644 --- a/src/NodeTypeResolver/Node/AttributeKey.php +++ b/src/NodeTypeResolver/Node/AttributeKey.php @@ -154,10 +154,6 @@ final class AttributeKey * @var string */ public const IS_MULTI_ASSIGN = 'is_multi_assign'; - /** - * @var string - */ - public const STATEMENT_DEPTH = 'statementDepth'; /** * @var string */ diff --git a/src/NodeTypeResolver/PHPStan/Scope/NodeVisitor/StmtKeyNodeVisitor.php b/src/NodeTypeResolver/PHPStan/Scope/NodeVisitor/StmtKeyNodeVisitor.php index b9ea9109e735..17b0af08ba5c 100644 --- a/src/NodeTypeResolver/PHPStan/Scope/NodeVisitor/StmtKeyNodeVisitor.php +++ b/src/NodeTypeResolver/PHPStan/Scope/NodeVisitor/StmtKeyNodeVisitor.php @@ -6,39 +6,12 @@ use PhpParser\Node; use PhpParser\Node\Stmt\ClassLike; use PhpParser\Node\Stmt\Declare_; -use PhpParser\Node\Stmt\Namespace_; use PhpParser\NodeVisitorAbstract; use Rector\Contract\PhpParser\Node\StmtsAwareInterface; use Rector\NodeTypeResolver\Node\AttributeKey; use Rector\NodeTypeResolver\PHPStan\Scope\Contract\NodeVisitor\ScopeResolverNodeVisitorInterface; final class StmtKeyNodeVisitor extends NodeVisitorAbstract implements ScopeResolverNodeVisitorInterface { - /** - * @param Node[] $nodes - */ - public function beforeTraverse(array $nodes) : ?array - { - if ($nodes === []) { - return null; - } - if (!$nodes[0] instanceof Declare_ && !$nodes[0] instanceof Namespace_) { - return null; - } - // on target node or no other root stmt, eg: only namespace without declare, no need to index - if (\count($nodes) === 1) { - return null; - } - // ensure statement depth is 0 to avoid declare in deep statements - // eg: declare(ticks=1) @see https://www.php.net/manual/en/control-structures.declare.php#123674 - $statementDepth = $nodes[0]->getAttribute(AttributeKey::STATEMENT_DEPTH); - if ($statementDepth > 0 || $statementDepth === null) { - return null; - } - foreach ($nodes as $key => $node) { - $node->setAttribute(AttributeKey::STMT_KEY, $key); - } - return $nodes; - } public function enterNode(Node $node) : ?Node { if (!$node instanceof StmtsAwareInterface && !$node instanceof ClassLike && !$node instanceof Declare_) {