1414use Rector \CodingStyle \ClassNameImport \UsedImportsResolver ;
1515use Rector \NodeTypeResolver \Node \AttributeKey ;
1616use Rector \NodeTypeResolver \PHPStan \Type \TypeFactory ;
17- use Rector \PhpParser \Node \CustomNode \ FileWithoutNamespace ;
17+ use Rector \PhpParser \Node \FileNode ;
1818use Rector \StaticTypeMapper \ValueObject \Type \AliasedObjectType ;
1919use Rector \StaticTypeMapper \ValueObject \Type \FullyQualifiedObjectType ;
2020
@@ -33,7 +33,7 @@ public function __construct(
3333 * @param array<FullyQualifiedObjectType|AliasedObjectType> $functionUseImportTypes
3434 */
3535 public function addImportsToStmts (
36- FileWithoutNamespace $ fileWithoutNamespace ,
36+ FileNode $ fileNode ,
3737 array $ stmts ,
3838 array $ useImportTypes ,
3939 array $ constantUseImportTypes ,
@@ -45,10 +45,12 @@ public function addImportsToStmts(
4545 $ existingFunctionUseImports = $ usedImports ->getFunctionImports ();
4646
4747 $ useImportTypes = $ this ->diffFullyQualifiedObjectTypes ($ useImportTypes , $ existingUseImportTypes );
48+
4849 $ constantUseImportTypes = $ this ->diffFullyQualifiedObjectTypes (
4950 $ constantUseImportTypes ,
5051 $ existingConstantUseImports
5152 );
53+
5254 $ functionUseImportTypes = $ this ->diffFullyQualifiedObjectTypes (
5355 $ functionUseImportTypes ,
5456 $ existingFunctionUseImports
@@ -90,17 +92,17 @@ public function addImportsToStmts(
9092
9193 array_splice ($ stmts , $ key + 1 , 0 , $ nodesToAdd );
9294
93- $ fileWithoutNamespace ->stmts = $ stmts ;
94- $ fileWithoutNamespace ->stmts = array_values ($ fileWithoutNamespace ->stmts );
95+ $ fileNode ->stmts = $ stmts ;
96+ $ fileNode ->stmts = array_values ($ fileNode ->stmts );
9597
9698 return true ;
9799 }
98100
99101 $ this ->mirrorUseComments ($ stmts , $ newUses );
100102
101103 // make use stmts first
102- $ fileWithoutNamespace ->stmts = array_merge ($ newUses , $ this ->resolveInsertNop ($ fileWithoutNamespace ), $ stmts );
103- $ fileWithoutNamespace ->stmts = array_values ($ fileWithoutNamespace ->stmts );
104+ $ fileNode ->stmts = array_merge ($ newUses , $ this ->resolveInsertNop ($ fileNode ), $ stmts );
105+ $ fileNode ->stmts = array_values ($ fileNode ->stmts );
104106
105107 return true ;
106108 }
@@ -154,7 +156,7 @@ public function addImportsToNamespace(
154156 /**
155157 * @return Nop[]
156158 */
157- private function resolveInsertNop (FileWithoutNamespace |Namespace_ $ namespace ): array
159+ private function resolveInsertNop (FileNode |Namespace_ $ namespace ): array
158160 {
159161 $ currentStmt = $ namespace ->stmts [0 ] ?? null ;
160162 if (! $ currentStmt instanceof Stmt || $ currentStmt instanceof Use_ || $ currentStmt instanceof GroupUse) {
0 commit comments