mirror of
https://github.com/rectorphp/rector.git
synced 2025-03-14 12:29:43 +01:00
Updated Rector to commit 7a65218f2442c2ad4e6d7ecbc55560408522fe08
7a65218f24
Remove auto import on changed files only to avoid too detailed setup and making ambiguous code (#3132)
This commit is contained in:
parent
a91bb662d1
commit
b84808cfa7
@ -35,17 +35,6 @@ Do you want to keep those?
|
||||
$rectorConfig->importShortClasses(false);
|
||||
```
|
||||
|
||||
<br>
|
||||
|
||||
If you have set `Option::AUTO_IMPORT_NAMES` to `true`, rector is applying this to every analyzed file, even if no real change by a rector was applied to the file.
|
||||
|
||||
The reason is that a so-called post-rector is responsible for this, namely the `NameImportingPostRector`.
|
||||
If you like to apply the Option::AUTO_IMPORT_NAMES only for real changed files, you can configure this.
|
||||
|
||||
```php
|
||||
$parameters->set(Option::APPLY_AUTO_IMPORT_NAMES_ON_CHANGED_FILES_ONLY, true);
|
||||
```
|
||||
|
||||
## How to Remove Unused Imports?
|
||||
|
||||
To remove imports, use [ECS](https://github.com/symplify/easy-coding-standard) with [`NoUnusedImportsFixer`](https://github.com/FriendsOfPHP/PHP-CS-Fixer/blob/2.18/doc/rules/import/no_unused_imports.rst) rule:
|
||||
|
@ -93,9 +93,6 @@ final class NameImportingPostRector extends \Rector\PostRector\Rector\AbstractPo
|
||||
if (!$file instanceof File) {
|
||||
return null;
|
||||
}
|
||||
if (!$this->shouldApply($file)) {
|
||||
return null;
|
||||
}
|
||||
if ($node instanceof Name) {
|
||||
return $this->processNodeName($node, $file);
|
||||
}
|
||||
@ -232,11 +229,4 @@ CODE_SAMPLE
|
||||
}
|
||||
return $this->reflectionProvider->hasFunction(new Name($name->getLast()), null);
|
||||
}
|
||||
private function shouldApply(File $file) : bool
|
||||
{
|
||||
if (!$this->parameterProvider->provideBoolParameter(Option::APPLY_AUTO_IMPORT_NAMES_ON_CHANGED_FILES_ONLY)) {
|
||||
return \true;
|
||||
}
|
||||
return $file->hasContentChanged();
|
||||
}
|
||||
}
|
||||
|
@ -17,12 +17,12 @@ final class VersionResolver
|
||||
* @api
|
||||
* @var string
|
||||
*/
|
||||
public const PACKAGE_VERSION = '7331d043786c1f74eff315fcc1d55032e9939dfc';
|
||||
public const PACKAGE_VERSION = '7a65218f2442c2ad4e6d7ecbc55560408522fe08';
|
||||
/**
|
||||
* @api
|
||||
* @var string
|
||||
*/
|
||||
public const RELEASE_DATE = '2022-11-30 07:58:39';
|
||||
public const RELEASE_DATE = '2022-11-30 07:33:38';
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
|
@ -140,6 +140,8 @@ final class Option
|
||||
public const AUTOLOAD_FILE_SHORT = 'a';
|
||||
/**
|
||||
* @var string
|
||||
* @deprecated
|
||||
* @api
|
||||
*/
|
||||
public const APPLY_AUTO_IMPORT_NAMES_ON_CHANGED_FILES_ONLY = 'apply_auto_import_names_on_changed_files_only';
|
||||
/**
|
||||
|
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 ComposerAutoloaderInitb8272d2cf355b448f9fc360d1873cab2::getLoader();
|
||||
return ComposerAutoloaderInit450b277fa7b5e00029f2e1b867341735::getLoader();
|
||||
|
14
vendor/composer/autoload_real.php
vendored
14
vendor/composer/autoload_real.php
vendored
@ -2,7 +2,7 @@
|
||||
|
||||
// autoload_real.php @generated by Composer
|
||||
|
||||
class ComposerAutoloaderInitb8272d2cf355b448f9fc360d1873cab2
|
||||
class ComposerAutoloaderInit450b277fa7b5e00029f2e1b867341735
|
||||
{
|
||||
private static $loader;
|
||||
|
||||
@ -22,19 +22,19 @@ class ComposerAutoloaderInitb8272d2cf355b448f9fc360d1873cab2
|
||||
return self::$loader;
|
||||
}
|
||||
|
||||
spl_autoload_register(array('ComposerAutoloaderInitb8272d2cf355b448f9fc360d1873cab2', 'loadClassLoader'), true, true);
|
||||
spl_autoload_register(array('ComposerAutoloaderInit450b277fa7b5e00029f2e1b867341735', 'loadClassLoader'), true, true);
|
||||
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__));
|
||||
spl_autoload_unregister(array('ComposerAutoloaderInitb8272d2cf355b448f9fc360d1873cab2', 'loadClassLoader'));
|
||||
spl_autoload_unregister(array('ComposerAutoloaderInit450b277fa7b5e00029f2e1b867341735', 'loadClassLoader'));
|
||||
|
||||
require __DIR__ . '/autoload_static.php';
|
||||
call_user_func(\Composer\Autoload\ComposerStaticInitb8272d2cf355b448f9fc360d1873cab2::getInitializer($loader));
|
||||
call_user_func(\Composer\Autoload\ComposerStaticInit450b277fa7b5e00029f2e1b867341735::getInitializer($loader));
|
||||
|
||||
$loader->setClassMapAuthoritative(true);
|
||||
$loader->register(true);
|
||||
|
||||
$includeFiles = \Composer\Autoload\ComposerStaticInitb8272d2cf355b448f9fc360d1873cab2::$files;
|
||||
$includeFiles = \Composer\Autoload\ComposerStaticInit450b277fa7b5e00029f2e1b867341735::$files;
|
||||
foreach ($includeFiles as $fileIdentifier => $file) {
|
||||
composerRequireb8272d2cf355b448f9fc360d1873cab2($fileIdentifier, $file);
|
||||
composerRequire450b277fa7b5e00029f2e1b867341735($fileIdentifier, $file);
|
||||
}
|
||||
|
||||
return $loader;
|
||||
@ -46,7 +46,7 @@ class ComposerAutoloaderInitb8272d2cf355b448f9fc360d1873cab2
|
||||
* @param string $file
|
||||
* @return void
|
||||
*/
|
||||
function composerRequireb8272d2cf355b448f9fc360d1873cab2($fileIdentifier, $file)
|
||||
function composerRequire450b277fa7b5e00029f2e1b867341735($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 ComposerStaticInitb8272d2cf355b448f9fc360d1873cab2
|
||||
class ComposerStaticInit450b277fa7b5e00029f2e1b867341735
|
||||
{
|
||||
public static $files = array (
|
||||
'ad155f8f1cf0d418fe49e248db8c661b' => __DIR__ . '/..' . '/react/promise/src/functions_include.php',
|
||||
@ -3021,9 +3021,9 @@ class ComposerStaticInitb8272d2cf355b448f9fc360d1873cab2
|
||||
public static function getInitializer(ClassLoader $loader)
|
||||
{
|
||||
return \Closure::bind(function () use ($loader) {
|
||||
$loader->prefixLengthsPsr4 = ComposerStaticInitb8272d2cf355b448f9fc360d1873cab2::$prefixLengthsPsr4;
|
||||
$loader->prefixDirsPsr4 = ComposerStaticInitb8272d2cf355b448f9fc360d1873cab2::$prefixDirsPsr4;
|
||||
$loader->classMap = ComposerStaticInitb8272d2cf355b448f9fc360d1873cab2::$classMap;
|
||||
$loader->prefixLengthsPsr4 = ComposerStaticInit450b277fa7b5e00029f2e1b867341735::$prefixLengthsPsr4;
|
||||
$loader->prefixDirsPsr4 = ComposerStaticInit450b277fa7b5e00029f2e1b867341735::$prefixDirsPsr4;
|
||||
$loader->classMap = ComposerStaticInit450b277fa7b5e00029f2e1b867341735::$classMap;
|
||||
|
||||
}, null, ClassLoader::class);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user