1010use PhpParser \Node \Expr ;
1111use PhpParser \Node \Expr \Array_ ;
1212use PhpParser \Node \Expr \ArrayDimFetch ;
13- use PhpParser \Node \Expr \ArrowFunction ;
1413use PhpParser \Node \Expr \Assign ;
1514use PhpParser \Node \Expr \AssignOp ;
1615use PhpParser \Node \Expr \AssignRef ;
2120use PhpParser \Node \Expr \Cast ;
2221use PhpParser \Node \Expr \ClassConstFetch ;
2322use PhpParser \Node \Expr \Clone_ ;
24- use PhpParser \Node \Expr \Closure ;
2523use PhpParser \Node \Expr \ConstFetch ;
2624use PhpParser \Node \Expr \Empty_ ;
2725use PhpParser \Node \Expr \ErrorSuppress ;
5654use PhpParser \Node \Name ;
5755use PhpParser \Node \Name \FullyQualified ;
5856use PhpParser \Node \NullableType ;
59- use PhpParser \Node \Param ;
6057use PhpParser \Node \Stmt ;
6158use PhpParser \Node \Stmt \Catch_ ;
6259use PhpParser \Node \Stmt \Class_ ;
63- use PhpParser \Node \Stmt \ClassConst ;
64- use PhpParser \Node \Stmt \ClassLike ;
65- use PhpParser \Node \Stmt \ClassMethod ;
6660use PhpParser \Node \Stmt \Do_ ;
6761use PhpParser \Node \Stmt \Echo_ ;
6862use PhpParser \Node \Stmt \ElseIf_ ;
7266use PhpParser \Node \Stmt \Finally_ ;
7367use PhpParser \Node \Stmt \For_ ;
7468use PhpParser \Node \Stmt \Foreach_ ;
75- use PhpParser \Node \Stmt \Function_ ;
7669use PhpParser \Node \Stmt \If_ ;
7770use PhpParser \Node \Stmt \Interface_ ;
7871use PhpParser \Node \Stmt \Property ;
@@ -207,8 +200,6 @@ public function processNodes(
207200 return ;
208201 }
209202
210- $ this ->decorateNodeAttrGroups ($ node , $ mutatingScope , $ nodeCallback );
211-
212203 if ((
213204 $ node instanceof Expression ||
214205 $ node instanceof Return_ ||
@@ -466,8 +457,8 @@ private function nodeScopeResolverProcessNodes(
466457 try {
467458 $ this ->nodeScopeResolver ->processNodes ($ stmts , $ mutatingScope , $ nodeCallback );
468459 } catch (ParserErrorsException |ParserException |ShouldNotHappenException |UndefinedVariableException ) {
469- // nothing we can do more precise here as error parsing from deep internal PHPStan service with service injection we cannot reset
470- // in the middle of process
460+ // nothing we can do more precise here as error parsing from deep internal PHPStan
461+ // service with service injection we cannot reset in the middle of process
471462 // fallback to fill by found scope
472463 RectorNodeScopeResolver ::processNodes ($ stmts , $ mutatingScope );
473464 }
@@ -528,40 +519,6 @@ private function processArrayItem(ArrayItem $arrayItem, MutatingScope $mutatingS
528519 }
529520 }
530521
531- /**
532- * @param callable(Node $trait, MutatingScope $scope): void $nodeCallback
533- */
534- private function decorateNodeAttrGroups (Node $ node , MutatingScope $ mutatingScope , callable $ nodeCallback ): void
535- {
536- // better to have AttrGroupsAwareInterface for all Node definition with attrGroups property
537- // but because may conflict with StmtsAwareInterface patch, this needs to be here
538- if (
539- ! $ node instanceof Param &&
540- ! $ node instanceof ArrowFunction &&
541- ! $ node instanceof Closure &&
542- ! $ node instanceof ClassConst &&
543- ! $ node instanceof ClassLike &&
544- ! $ node instanceof ClassMethod &&
545- ! $ node instanceof EnumCase &&
546- ! $ node instanceof Function_ &&
547- ! $ node instanceof Property
548- ) {
549- return ;
550- }
551-
552- foreach ($ node ->attrGroups as $ attrGroup ) {
553- foreach ($ attrGroup ->attrs as $ attr ) {
554- foreach ($ attr ->args as $ arg ) {
555- $ this ->nodeScopeResolverProcessNodes (
556- [new Expression ($ arg ->value )],
557- $ mutatingScope ,
558- $ nodeCallback
559- );
560- }
561- }
562- }
563- }
564-
565522 private function processSwitch (Switch_ $ switch , MutatingScope $ mutatingScope ): void
566523 {
567524 $ switch ->cond ->setAttribute (AttributeKey::SCOPE , $ mutatingScope );
@@ -682,11 +639,6 @@ private function resolveClassOrInterfaceScope(
682639 $ context = $ this ->privatesAccessor ->getPrivateProperty ($ mutatingScope , 'context ' );
683640 $ this ->privatesAccessor ->setPrivateProperty ($ context , 'classReflection ' , null );
684641
685- try {
686- return $ mutatingScope ->enterClass ($ classReflection );
687- } catch (ShouldNotHappenException ) {
688- }
689-
690642 return $ mutatingScope ;
691643 }
692644
@@ -713,7 +665,6 @@ private function processTrait(Trait_ $trait, MutatingScope $mutatingScope, calla
713665 if (! $ this ->reflectionProvider ->hasClass ($ traitName )) {
714666 $ trait ->setAttribute (AttributeKey::SCOPE , $ mutatingScope );
715667 $ this ->nodeScopeResolverProcessNodes ($ trait ->stmts , $ mutatingScope , $ nodeCallback );
716- $ this ->decorateNodeAttrGroups ($ trait , $ mutatingScope , $ nodeCallback );
717668
718669 return ;
719670 }
@@ -736,6 +687,5 @@ private function processTrait(Trait_ $trait, MutatingScope $mutatingScope, calla
736687
737688 $ trait ->setAttribute (AttributeKey::SCOPE , $ traitScope );
738689 $ this ->nodeScopeResolverProcessNodes ($ trait ->stmts , $ traitScope , $ nodeCallback );
739- $ this ->decorateNodeAttrGroups ($ trait , $ traitScope , $ nodeCallback );
740690 }
741691}
0 commit comments