diff --git a/rules/CodingStyle/Rector/Use_/SeparateMultiUseImportsRector.php b/rules/CodingStyle/Rector/Use_/SeparateMultiUseImportsRector.php index 69754d20d6b..1ba5d6fb1ce 100644 --- a/rules/CodingStyle/Rector/Use_/SeparateMultiUseImportsRector.php +++ b/rules/CodingStyle/Rector/Use_/SeparateMultiUseImportsRector.php @@ -4,8 +4,11 @@ declare (strict_types=1); namespace Rector\CodingStyle\Rector\Use_; use PhpParser\Node; +use PhpParser\Node\Stmt\Class_; +use PhpParser\Node\Stmt\Namespace_; use PhpParser\Node\Stmt\TraitUse; use PhpParser\Node\Stmt\Use_; +use Rector\Core\PhpParser\Node\CustomNode\FileWithoutNamespace; use Rector\Core\Rector\AbstractRector; use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; @@ -41,18 +44,38 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [Use_::class, TraitUse::class]; + return [FileWithoutNamespace::class, Namespace_::class, Class_::class]; } /** - * @param Use_|TraitUse $node - * @return Use_[]|TraitUse[]|null + * @param FileWithoutNamespace|Namespace_|Class_ $node + * @return \Rector\Core\PhpParser\Node\CustomNode\FileWithoutNamespace|\PhpParser\Node\Stmt\Namespace_|\PhpParser\Node\Stmt\Class_|null */ - public function refactor(Node $node) : ?array + public function refactor(Node $node) { - if ($node instanceof Use_) { - return $this->refactorUseImport($node); + $hasChanged = \false; + foreach ($node->stmts as $key => $stmt) { + if ($stmt instanceof Use_) { + $refactorUseImport = $this->refactorUseImport($stmt); + if ($refactorUseImport !== null) { + unset($node->stmts[$key]); + \array_splice($node->stmts, $key, 0, $refactorUseImport); + $hasChanged = \true; + } + continue; + } + if ($stmt instanceof TraitUse) { + $refactorTraitUse = $this->refactorTraitUse($stmt); + if ($refactorTraitUse !== null) { + unset($node->stmts[$key]); + \array_splice($node->stmts, $key, 0, $refactorTraitUse); + $hasChanged = \true; + } + } } - return $this->refactorTraitUse($node); + if (!$hasChanged) { + return null; + } + return $node; } /** * @return Use_[]|null $use diff --git a/src/Application/VersionResolver.php b/src/Application/VersionResolver.php index 97cc933603f..2613c984c48 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 = '529defd2de2b8ea122d0d7326ca0b054a22a030d'; + public const PACKAGE_VERSION = '58273de24474dee2a5463949ad127a86526c4e3a'; /** * @api * @var string */ - public const RELEASE_DATE = '2023-08-04 21:07:35'; + public const RELEASE_DATE = '2023-08-04 22:22:48'; /** * @var int */ diff --git a/vendor/autoload.php b/vendor/autoload.php index 78ee1417d49..e8b6e9eb411 100644 --- a/vendor/autoload.php +++ b/vendor/autoload.php @@ -22,4 +22,4 @@ if (PHP_VERSION_ID < 50600) { require_once __DIR__ . '/composer/autoload_real.php'; -return ComposerAutoloaderInitaed1c703ebc52bf0bfb9c0829d01beb1::getLoader(); +return ComposerAutoloaderIniteba2d00fce57247563ebbdd0a16175fc::getLoader(); diff --git a/vendor/composer/autoload_real.php b/vendor/composer/autoload_real.php index e07d860714a..5019deea99f 100644 --- a/vendor/composer/autoload_real.php +++ b/vendor/composer/autoload_real.php @@ -2,7 +2,7 @@ // autoload_real.php @generated by Composer -class ComposerAutoloaderInitaed1c703ebc52bf0bfb9c0829d01beb1 +class ComposerAutoloaderIniteba2d00fce57247563ebbdd0a16175fc { private static $loader; @@ -22,17 +22,17 @@ class ComposerAutoloaderInitaed1c703ebc52bf0bfb9c0829d01beb1 return self::$loader; } - spl_autoload_register(array('ComposerAutoloaderInitaed1c703ebc52bf0bfb9c0829d01beb1', 'loadClassLoader'), true, true); + spl_autoload_register(array('ComposerAutoloaderIniteba2d00fce57247563ebbdd0a16175fc', 'loadClassLoader'), true, true); self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__)); - spl_autoload_unregister(array('ComposerAutoloaderInitaed1c703ebc52bf0bfb9c0829d01beb1', 'loadClassLoader')); + spl_autoload_unregister(array('ComposerAutoloaderIniteba2d00fce57247563ebbdd0a16175fc', 'loadClassLoader')); require __DIR__ . '/autoload_static.php'; - call_user_func(\Composer\Autoload\ComposerStaticInitaed1c703ebc52bf0bfb9c0829d01beb1::getInitializer($loader)); + call_user_func(\Composer\Autoload\ComposerStaticIniteba2d00fce57247563ebbdd0a16175fc::getInitializer($loader)); $loader->setClassMapAuthoritative(true); $loader->register(true); - $filesToLoad = \Composer\Autoload\ComposerStaticInitaed1c703ebc52bf0bfb9c0829d01beb1::$files; + $filesToLoad = \Composer\Autoload\ComposerStaticIniteba2d00fce57247563ebbdd0a16175fc::$files; $requireFile = \Closure::bind(static function ($fileIdentifier, $file) { if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) { $GLOBALS['__composer_autoload_files'][$fileIdentifier] = true; diff --git a/vendor/composer/autoload_static.php b/vendor/composer/autoload_static.php index 7ef139660c6..f08b4c96328 100644 --- a/vendor/composer/autoload_static.php +++ b/vendor/composer/autoload_static.php @@ -4,7 +4,7 @@ namespace Composer\Autoload; -class ComposerStaticInitaed1c703ebc52bf0bfb9c0829d01beb1 +class ComposerStaticIniteba2d00fce57247563ebbdd0a16175fc { public static $files = array ( 'ad155f8f1cf0d418fe49e248db8c661b' => __DIR__ . '/..' . '/react/promise/src/functions_include.php', @@ -3014,9 +3014,9 @@ class ComposerStaticInitaed1c703ebc52bf0bfb9c0829d01beb1 public static function getInitializer(ClassLoader $loader) { return \Closure::bind(function () use ($loader) { - $loader->prefixLengthsPsr4 = ComposerStaticInitaed1c703ebc52bf0bfb9c0829d01beb1::$prefixLengthsPsr4; - $loader->prefixDirsPsr4 = ComposerStaticInitaed1c703ebc52bf0bfb9c0829d01beb1::$prefixDirsPsr4; - $loader->classMap = ComposerStaticInitaed1c703ebc52bf0bfb9c0829d01beb1::$classMap; + $loader->prefixLengthsPsr4 = ComposerStaticIniteba2d00fce57247563ebbdd0a16175fc::$prefixLengthsPsr4; + $loader->prefixDirsPsr4 = ComposerStaticIniteba2d00fce57247563ebbdd0a16175fc::$prefixDirsPsr4; + $loader->classMap = ComposerStaticIniteba2d00fce57247563ebbdd0a16175fc::$classMap; }, null, ClassLoader::class); }