File tree Expand file tree Collapse file tree 5 files changed +7
-27
lines changed
rules/DeadCode/Rector/Assign
NodeTypeResolver/PHPStan/Scope/NodeVisitor Expand file tree Collapse file tree 5 files changed +7
-27
lines changed Original file line number Diff line number Diff line change @@ -55,23 +55,22 @@ public function getNodeTypes(): array
5555 */
5656 public function refactor (Node $ node ): ?Node
5757 {
58- $ stmts = $ node ->stmts ;
59- if ($ stmts === null ) {
58+ if ($ node ->stmts === null ) {
6059 return null ;
6160 }
6261
6362 $ hasChanged = false ;
6463
65- foreach ($ stmts as $ key => $ stmt ) {
66- if (! isset ($ stmts [$ key + 1 ])) {
64+ foreach ($ node -> stmts as $ key => $ stmt ) {
65+ if (! isset ($ node -> stmts [$ key + 1 ])) {
6766 continue ;
6867 }
6968
7069 if (! $ stmt instanceof Expression) {
7170 continue ;
7271 }
7372
74- $ nextStmt = $ stmts [$ key + 1 ];
73+ $ nextStmt = $ node -> stmts [$ key + 1 ];
7574 if (! $ nextStmt instanceof Expression) {
7675 continue ;
7776 }
Original file line number Diff line number Diff line change @@ -36,6 +36,7 @@ public static function reIndexStmtsKeys(Node $node): ?Node
3636 }
3737
3838 $ node ->stmts = array_values ($ node ->stmts );
39+
3940 return $ node ;
4041 }
4142
Original file line number Diff line number Diff line change 103103use Rector \NodeTypeResolver \PHPStan \Scope \NodeVisitor \GlobalVariableNodeVisitor ;
104104use Rector \NodeTypeResolver \PHPStan \Scope \NodeVisitor \NameNodeVisitor ;
105105use Rector \NodeTypeResolver \PHPStan \Scope \NodeVisitor \StaticVariableNodeVisitor ;
106- use Rector \NodeTypeResolver \PHPStan \Scope \NodeVisitor \StmtKeyNodeVisitor ;
107106use Rector \NodeTypeResolver \PHPStan \Scope \PHPStanNodeScopeResolver ;
108107use Rector \NodeTypeResolver \Reflection \BetterReflection \SourceLocatorProvider \DynamicSourceLocatorProvider ;
109108use Rector \Php80 \AttributeDecorator \DoctrineConverterAttributeDecorator ;
@@ -243,7 +242,6 @@ final class LazyContainerFactory
243242 GlobalVariableNodeVisitor::class,
244243 NameNodeVisitor::class,
245244 StaticVariableNodeVisitor::class,
246- StmtKeyNodeVisitor::class,
247245 ];
248246
249247 /**
Load Diff This file was deleted.
Original file line number Diff line number Diff line change @@ -139,8 +139,6 @@ final public function enterNode(Node $node): int|Node|null
139139 // ensure origNode pulled before refactor to avoid changed during refactor, ref https://3v4l.org/YMEGN
140140 $ originalNode = $ node ->getAttribute (AttributeKey::ORIGINAL_NODE ) ?? $ node ;
141141
142- NodeAttributeReIndexer::reIndexNodeAttributes ($ node );
143-
144142 $ refactoredNode = $ this ->refactor ($ node );
145143
146144 // nothing to change → continue
@@ -153,6 +151,8 @@ final public function enterNode(Node $node): int|Node|null
153151 throw new ShouldNotHappenException ($ errorMessage );
154152 }
155153
154+ NodeAttributeReIndexer::reIndexNodeAttributes ($ node );
155+
156156 $ isIntRefactoredNode = is_int ($ refactoredNode );
157157
158158 /**
You can’t perform that action at this time.
0 commit comments