From f0e6c7a987701ecc1e26139c27363d2605f4b77f Mon Sep 17 00:00:00 2001 From: Abdul Malik Ikhsan Date: Sun, 30 Nov 2025 08:35:15 +0700 Subject: [PATCH 1/2] [PhpParser] Add Stmt\Block to NodeGroup::STMTS_AWARE --- phpstan.neon | 2 +- src/Application/NodeAttributeReIndexer.php | 2 +- src/PhpParser/Enum/NodeGroup.php | 2 ++ 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/phpstan.neon b/phpstan.neon index 4020702fc6f..70f3fade031 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -10,7 +10,7 @@ parameters: # see https://phpstan.org/writing-php-code/phpdoc-types#global-type-aliases typeAliases: - StmtsAware: \PhpParser\Node\Expr\Closure | \PhpParser\Node\Stmt\Case_ | \PhpParser\Node\Stmt\Catch_ | \PhpParser\Node\Stmt\ClassMethod | \PhpParser\Node\Stmt\Do_ | \PhpParser\Node\Stmt\Else_ | \PhpParser\Node\Stmt\ElseIf_ | \PhpParser\Node\Stmt\Finally_ | \PhpParser\Node\Stmt\For_ | \PhpParser\Node\Stmt\Foreach_ | \PhpParser\Node\Stmt\Function_ | \PhpParser\Node\Stmt\If_ | \PhpParser\Node\Stmt\Namespace_ | \PhpParser\Node\Stmt\TryCatch | \PhpParser\Node\Stmt\While_ + StmtsAware: \PhpParser\Node\Stmt\Block | \PhpParser\Node\Expr\Closure | \PhpParser\Node\Stmt\Case_ | \PhpParser\Node\Stmt\Catch_ | \PhpParser\Node\Stmt\ClassMethod | \PhpParser\Node\Stmt\Do_ | \PhpParser\Node\Stmt\Else_ | \PhpParser\Node\Stmt\ElseIf_ | \PhpParser\Node\Stmt\Finally_ | \PhpParser\Node\Stmt\For_ | \PhpParser\Node\Stmt\Foreach_ | \PhpParser\Node\Stmt\Function_ | \PhpParser\Node\Stmt\If_ | \PhpParser\Node\Stmt\Namespace_ | \PhpParser\Node\Stmt\TryCatch | \PhpParser\Node\Stmt\While_ | \Rector\PhpParser\Node\CustomNode\FileWithoutNamespace # requires exact closure types checkMissingCallableSignature: true diff --git a/src/Application/NodeAttributeReIndexer.php b/src/Application/NodeAttributeReIndexer.php index f1a4d747d1e..ef33bf8ec85 100644 --- a/src/Application/NodeAttributeReIndexer.php +++ b/src/Application/NodeAttributeReIndexer.php @@ -69,7 +69,7 @@ private static function reIndexStmtsKeys(Node $node): ?Node { if (! NodeGroup::isStmtAwareNode( $node - ) && ! $node instanceof ClassLike && ! $node instanceof Declare_ && ! $node instanceof Block) { + ) && ! $node instanceof ClassLike && ! $node instanceof Declare_) { return null; } diff --git a/src/PhpParser/Enum/NodeGroup.php b/src/PhpParser/Enum/NodeGroup.php index 9a1bb72d477..871e8de9d5c 100644 --- a/src/PhpParser/Enum/NodeGroup.php +++ b/src/PhpParser/Enum/NodeGroup.php @@ -6,6 +6,7 @@ use PhpParser\Node; use PhpParser\Node\Expr\Closure; +use PhpParser\Node\Stmt\Block; use PhpParser\Node\Stmt\Case_; use PhpParser\Node\Stmt\Catch_; use PhpParser\Node\Stmt\Class_; @@ -38,6 +39,7 @@ final class NodeGroup * @var array> */ public const STMTS_AWARE = [ + Block::class, Closure::class, Case_::class, Catch_::class, From 07b7a7cc95227c4213eda5faa0101beecc53cd51 Mon Sep 17 00:00:00 2001 From: GitHub Action Date: Sun, 30 Nov 2025 01:40:45 +0000 Subject: [PATCH 2/2] [ci-review] Rector Rectify --- src/Application/NodeAttributeReIndexer.php | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Application/NodeAttributeReIndexer.php b/src/Application/NodeAttributeReIndexer.php index ef33bf8ec85..23e588b2c69 100644 --- a/src/Application/NodeAttributeReIndexer.php +++ b/src/Application/NodeAttributeReIndexer.php @@ -13,7 +13,6 @@ use PhpParser\Node\Expr\NullsafeMethodCall; use PhpParser\Node\Expr\StaticCall; use PhpParser\Node\FunctionLike; -use PhpParser\Node\Stmt\Block; use PhpParser\Node\Stmt\ClassLike; use PhpParser\Node\Stmt\ClassMethod; use PhpParser\Node\Stmt\Declare_;