@@ -99,12 +99,21 @@ public function autowire(
9999 }
100100
101101 /**
102- * @final Avoid override to prevent unintended side-effects. Use enterNode() or @see \Rector\Contract\PhpParser\DecoratingNodeVisitorInterface instead.
103- * @internal
102+ * @return Node[]|null
104103 *
104+ * @internal
105+ */
106+ final public function beforeTraverse (array $ nodes ): ?array
107+ {
108+ return null ;
109+ }
110+
111+ /**
105112 * @return Node[]|null
113+ *
114+ * @internal
106115 */
107- public function beforeTraverse (array $ nodes ): ? array
116+ final public function afterTraverse (array $ nodes )
108117 {
109118 return null ;
110119 }
@@ -115,13 +124,13 @@ public function beforeTraverse(array $nodes): ?array
115124 final public function enterNode (Node $ node ): int |Node |null |array
116125 {
117126 // keep $this->file populated for BC; refactor() is only ever reached through here
118- $ file = $ this ->file = $ this ->getFile ();
127+ $ this ->file = $ this ->getFile ();
119128
120- if (is_a ($ this , HTMLAverseRectorInterface::class, true ) && $ file ->containsHTML ()) {
129+ if (is_a ($ this , HTMLAverseRectorInterface::class, true ) && $ this -> file ->containsHTML ()) {
121130 return null ;
122131 }
123132
124- $ filePath = $ file ->getFilePath ();
133+ $ filePath = $ this -> file ->getFilePath ();
125134 if ($ this ->skipper ->shouldSkipCurrentNode ($ this , $ filePath , static ::class, $ node )) {
126135 return null ;
127136 }
@@ -154,7 +163,7 @@ final public function enterNode(Node $node): int|Node|null|array
154163
155164 // notify this rule changed code
156165 $ rectorWithLineChange = new RectorWithLineChange (static ::class, $ originalNode ->getStartLine ());
157- $ file ->addRectorClassWithLine ($ rectorWithLineChange );
166+ $ this -> file ->addRectorClassWithLine ($ rectorWithLineChange );
158167
159168 return $ refactoredNodeOrState ;
160169 }
@@ -264,8 +273,7 @@ private function postRefactorProcess(
264273 $ this ->createdByRuleDecorator ->decorate ($ refactoredNode , $ originalNode , static ::class);
265274
266275 $ rectorWithLineChange = new RectorWithLineChange (static ::class, $ originalNode ->getStartLine ());
267- $ this ->getFile ()
268- ->addRectorClassWithLine ($ rectorWithLineChange );
276+ $ this ->file ->addRectorClassWithLine ($ rectorWithLineChange );
269277
270278 /** @var MutatingScope|null $currentScope */
271279 $ currentScope = $ node ->getAttribute (AttributeKey::SCOPE );
0 commit comments