diff --git a/packages/PostRector/Rector/NameImportingPostRector.php b/packages/PostRector/Rector/NameImportingPostRector.php index fca0387d72b..d932732ad93 100644 --- a/packages/PostRector/Rector/NameImportingPostRector.php +++ b/packages/PostRector/Rector/NameImportingPostRector.php @@ -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; } diff --git a/rules/CodingStyle/Application/UseImportsAdder.php b/rules/CodingStyle/Application/UseImportsAdder.php index 4bed4c783a3..14104606e14 100644 --- a/rules/CodingStyle/Application/UseImportsAdder.php +++ b/rules/CodingStyle/Application/UseImportsAdder.php @@ -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 diff --git a/src/Application/VersionResolver.php b/src/Application/VersionResolver.php index e7d172863cc..c6588ac1773 100644 --- a/src/Application/VersionResolver.php +++ b/src/Application/VersionResolver.php @@ -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 */