mirror of
https://github.com/rectorphp/rector.git
synced 2025-01-29 19:37:55 +01:00
Updated Rector to commit 291aab4a2afd397cff1a37078b0c5b559f5299de
291aab4a2a
[AutoImport] Add mirror comment support on first Use_ on no namespace code (#3465)
This commit is contained in:
parent
84c00e601b
commit
5e6f195e17
@ -32,6 +32,23 @@ final class UseImportsAdder
|
||||
$this->usedImportsResolver = $usedImportsResolver;
|
||||
$this->typeFactory = $typeFactory;
|
||||
}
|
||||
/**
|
||||
* @param Stmt[] $stmts
|
||||
* @param Use_[] $newUses
|
||||
*/
|
||||
private function mirrorUseComments(array $stmts, array $newUses, int $indexStmt = 0) : void
|
||||
{
|
||||
if ($stmts === []) {
|
||||
return;
|
||||
}
|
||||
if ($stmts[$indexStmt] instanceof Use_) {
|
||||
$comments = (array) $stmts[$indexStmt]->getAttribute(AttributeKey::COMMENTS);
|
||||
if ($comments !== []) {
|
||||
$newUses[0]->setAttribute(AttributeKey::COMMENTS, $stmts[$indexStmt]->getAttribute(AttributeKey::COMMENTS));
|
||||
$stmts[$indexStmt]->setAttribute(AttributeKey::COMMENTS, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* @param Stmt[] $stmts
|
||||
* @param array<FullyQualifiedObjectType|AliasedObjectType> $useImportTypes
|
||||
@ -57,10 +74,12 @@ final class UseImportsAdder
|
||||
// add extra space, if there are no new use imports to be added
|
||||
$nodesToAdd = \array_merge([new Nop()], $newUses);
|
||||
}
|
||||
$this->mirrorUseComments($stmts, $newUses, $key + 1);
|
||||
\array_splice($stmts, $key + 1, 0, $nodesToAdd);
|
||||
return $stmts;
|
||||
}
|
||||
}
|
||||
$this->mirrorUseComments($stmts, $newUses);
|
||||
// make use stmts first
|
||||
return \array_merge($newUses, $stmts);
|
||||
}
|
||||
@ -80,13 +99,7 @@ final class UseImportsAdder
|
||||
if ($newUses === []) {
|
||||
return;
|
||||
}
|
||||
if ($namespace->stmts[0] instanceof Use_) {
|
||||
$comments = (array) $namespace->stmts[0]->getAttribute(AttributeKey::COMMENTS);
|
||||
if ($comments !== []) {
|
||||
$newUses[0]->setAttribute(AttributeKey::COMMENTS, $namespace->stmts[0]->getAttribute(AttributeKey::COMMENTS));
|
||||
$namespace->stmts[0]->setAttribute(AttributeKey::COMMENTS, null);
|
||||
}
|
||||
}
|
||||
$this->mirrorUseComments($namespace->stmts, $newUses);
|
||||
$namespace->stmts = \array_merge($newUses, $namespace->stmts);
|
||||
}
|
||||
/**
|
||||
|
@ -19,12 +19,12 @@ final class VersionResolver
|
||||
* @api
|
||||
* @var string
|
||||
*/
|
||||
public const PACKAGE_VERSION = 'ed5caee5b1cdecf12b77b1f2944dde539a3b004f';
|
||||
public const PACKAGE_VERSION = '291aab4a2afd397cff1a37078b0c5b559f5299de';
|
||||
/**
|
||||
* @api
|
||||
* @var string
|
||||
*/
|
||||
public const RELEASE_DATE = '2023-03-08 14:02:57';
|
||||
public const RELEASE_DATE = '2023-03-08 15:18:55';
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
|
2
vendor/autoload.php
vendored
2
vendor/autoload.php
vendored
@ -22,4 +22,4 @@ if (PHP_VERSION_ID < 50600) {
|
||||
|
||||
require_once __DIR__ . '/composer/autoload_real.php';
|
||||
|
||||
return ComposerAutoloaderInit87f66dc792c35c6466cef09b5c022d13::getLoader();
|
||||
return ComposerAutoloaderInit54753c9f52f143cde46d71a7987471d5::getLoader();
|
||||
|
10
vendor/composer/autoload_real.php
vendored
10
vendor/composer/autoload_real.php
vendored
@ -2,7 +2,7 @@
|
||||
|
||||
// autoload_real.php @generated by Composer
|
||||
|
||||
class ComposerAutoloaderInit87f66dc792c35c6466cef09b5c022d13
|
||||
class ComposerAutoloaderInit54753c9f52f143cde46d71a7987471d5
|
||||
{
|
||||
private static $loader;
|
||||
|
||||
@ -22,17 +22,17 @@ class ComposerAutoloaderInit87f66dc792c35c6466cef09b5c022d13
|
||||
return self::$loader;
|
||||
}
|
||||
|
||||
spl_autoload_register(array('ComposerAutoloaderInit87f66dc792c35c6466cef09b5c022d13', 'loadClassLoader'), true, true);
|
||||
spl_autoload_register(array('ComposerAutoloaderInit54753c9f52f143cde46d71a7987471d5', 'loadClassLoader'), true, true);
|
||||
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__));
|
||||
spl_autoload_unregister(array('ComposerAutoloaderInit87f66dc792c35c6466cef09b5c022d13', 'loadClassLoader'));
|
||||
spl_autoload_unregister(array('ComposerAutoloaderInit54753c9f52f143cde46d71a7987471d5', 'loadClassLoader'));
|
||||
|
||||
require __DIR__ . '/autoload_static.php';
|
||||
call_user_func(\Composer\Autoload\ComposerStaticInit87f66dc792c35c6466cef09b5c022d13::getInitializer($loader));
|
||||
call_user_func(\Composer\Autoload\ComposerStaticInit54753c9f52f143cde46d71a7987471d5::getInitializer($loader));
|
||||
|
||||
$loader->setClassMapAuthoritative(true);
|
||||
$loader->register(true);
|
||||
|
||||
$filesToLoad = \Composer\Autoload\ComposerStaticInit87f66dc792c35c6466cef09b5c022d13::$files;
|
||||
$filesToLoad = \Composer\Autoload\ComposerStaticInit54753c9f52f143cde46d71a7987471d5::$files;
|
||||
$requireFile = \Closure::bind(static function ($fileIdentifier, $file) {
|
||||
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
|
||||
$GLOBALS['__composer_autoload_files'][$fileIdentifier] = true;
|
||||
|
8
vendor/composer/autoload_static.php
vendored
8
vendor/composer/autoload_static.php
vendored
@ -4,7 +4,7 @@
|
||||
|
||||
namespace Composer\Autoload;
|
||||
|
||||
class ComposerStaticInit87f66dc792c35c6466cef09b5c022d13
|
||||
class ComposerStaticInit54753c9f52f143cde46d71a7987471d5
|
||||
{
|
||||
public static $files = array (
|
||||
'ad155f8f1cf0d418fe49e248db8c661b' => __DIR__ . '/..' . '/react/promise/src/functions_include.php',
|
||||
@ -3133,9 +3133,9 @@ class ComposerStaticInit87f66dc792c35c6466cef09b5c022d13
|
||||
public static function getInitializer(ClassLoader $loader)
|
||||
{
|
||||
return \Closure::bind(function () use ($loader) {
|
||||
$loader->prefixLengthsPsr4 = ComposerStaticInit87f66dc792c35c6466cef09b5c022d13::$prefixLengthsPsr4;
|
||||
$loader->prefixDirsPsr4 = ComposerStaticInit87f66dc792c35c6466cef09b5c022d13::$prefixDirsPsr4;
|
||||
$loader->classMap = ComposerStaticInit87f66dc792c35c6466cef09b5c022d13::$classMap;
|
||||
$loader->prefixLengthsPsr4 = ComposerStaticInit54753c9f52f143cde46d71a7987471d5::$prefixLengthsPsr4;
|
||||
$loader->prefixDirsPsr4 = ComposerStaticInit54753c9f52f143cde46d71a7987471d5::$prefixDirsPsr4;
|
||||
$loader->classMap = ComposerStaticInit54753c9f52f143cde46d71a7987471d5::$classMap;
|
||||
|
||||
}, null, ClassLoader::class);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user