mirror of https://github.com/rectorphp/rector.git
Updated Rector to commit 1595e34d12d856eab8e2478de357f0b1dff3556f
1595e34d12
[CodingStyle] Refactor UseImportsAdder to return [FileWithoutNamespace] code on no namespaced code (#5254)
This commit is contained in:
parent
b4cef81b9f
commit
1d5d0dd30b
|
@ -120,13 +120,8 @@ final class NameImportingPostRector extends \Rector\PostRector\Rector\AbstractPo
|
|||
return null;
|
||||
}
|
||||
$namespaces = \array_filter($file->getNewStmts(), static function (Stmt $stmt) : bool {
|
||||
return $stmt instanceof Namespace_ || $stmt instanceof FileWithoutNamespace;
|
||||
return $stmt instanceof Namespace_;
|
||||
});
|
||||
// handle overlapped resolve last new stmts
|
||||
// @see https://github.com/rectorphp/rector-src/pull/5251
|
||||
if ($namespaces === []) {
|
||||
return null;
|
||||
}
|
||||
if (\count($namespaces) > 1) {
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -52,7 +52,7 @@ final class UseImportsAdder
|
|||
$functionUseImportTypes = $this->diffFullyQualifiedObjectTypes($functionUseImportTypes, $existingFunctionUseImports);
|
||||
$newUses = $this->createUses($useImportTypes, $constantUseImportTypes, $functionUseImportTypes, null);
|
||||
if ($newUses === []) {
|
||||
return $stmts;
|
||||
return [$fileWithoutNamespace];
|
||||
}
|
||||
// place after declare strict_types
|
||||
foreach ($stmts as $key => $stmt) {
|
||||
|
@ -67,14 +67,14 @@ final class UseImportsAdder
|
|||
\array_splice($stmts, $key + 1, 0, $nodesToAdd);
|
||||
$fileWithoutNamespace->stmts = $stmts;
|
||||
$fileWithoutNamespace->stmts = \array_values($fileWithoutNamespace->stmts);
|
||||
return $fileWithoutNamespace->stmts;
|
||||
return [$fileWithoutNamespace];
|
||||
}
|
||||
}
|
||||
$this->mirrorUseComments($stmts, $newUses);
|
||||
// make use stmts first
|
||||
$fileWithoutNamespace->stmts = \array_merge($newUses, $stmts);
|
||||
$fileWithoutNamespace->stmts = \array_values($fileWithoutNamespace->stmts);
|
||||
return $fileWithoutNamespace->stmts;
|
||||
return [$fileWithoutNamespace];
|
||||
}
|
||||
/**
|
||||
* @param FullyQualifiedObjectType[] $useImportTypes
|
||||
|
|
|
@ -19,12 +19,12 @@ final class VersionResolver
|
|||
* @api
|
||||
* @var string
|
||||
*/
|
||||
public const PACKAGE_VERSION = '60047ce7785545401ad870d483060ce640fa3369';
|
||||
public const PACKAGE_VERSION = '1595e34d12d856eab8e2478de357f0b1dff3556f';
|
||||
/**
|
||||
* @api
|
||||
* @var string
|
||||
*/
|
||||
public const RELEASE_DATE = '2023-11-16 12:34:15';
|
||||
public const RELEASE_DATE = '2023-11-16 21:49:13';
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
|
|
Loading…
Reference in New Issue