From baee5d9d4a82027584c8766054e906cf75fcd487 Mon Sep 17 00:00:00 2001 From: Tomas Votruba Date: Thu, 23 Feb 2023 10:31:39 +0000 Subject: [PATCH] Updated Rector to commit 48e97cb0e710d6b7d704d31a6e3c4320486e1ed4 https://github.com/rectorphp/rector-src/commit/48e97cb0e710d6b7d704d31a6e3c4320486e1ed4 [Core][e2e] Do not reprint from PhpParser when no RectorWithLineChange or empty diff (#3403) --- ...yQualifiedNameClassNameImportSkipVoter.php | 6 ++---- .../FileProcessor/PhpFileProcessor.php | 19 ++++++++++++++++--- src/Application/VersionResolver.php | 4 ++-- vendor/autoload.php | 2 +- vendor/composer/autoload_real.php | 10 +++++----- vendor/composer/autoload_static.php | 8 ++++---- 6 files changed, 30 insertions(+), 19 deletions(-) diff --git a/rules/CodingStyle/ClassNameImport/ClassNameImportSkipVoter/FullyQualifiedNameClassNameImportSkipVoter.php b/rules/CodingStyle/ClassNameImport/ClassNameImportSkipVoter/FullyQualifiedNameClassNameImportSkipVoter.php index bc4ed53e5b0..1b7370e9c31 100644 --- a/rules/CodingStyle/ClassNameImport/ClassNameImportSkipVoter/FullyQualifiedNameClassNameImportSkipVoter.php +++ b/rules/CodingStyle/ClassNameImport/ClassNameImportSkipVoter/FullyQualifiedNameClassNameImportSkipVoter.php @@ -33,13 +33,11 @@ final class FullyQualifiedNameClassNameImportSkipVoter implements ClassNameImpor // "new X" or "X::static()" /** @var array $shortNamesToFullyQualifiedNames */ $shortNamesToFullyQualifiedNames = $this->shortNameResolver->resolveFromFile($file); - $loweredShortNameFullyQualified = $fullyQualifiedObjectType->getShortNameLowered(); foreach ($shortNamesToFullyQualifiedNames as $shortName => $fullyQualifiedName) { - $shortNameLowered = \strtolower($shortName); - if ($loweredShortNameFullyQualified !== $shortNameLowered) { + if ($fullyQualifiedObjectType->getShortName() !== $shortName) { continue; } - return $fullyQualifiedObjectType->getClassNameLowered() !== \strtolower($fullyQualifiedName); + return $fullyQualifiedObjectType->getClassName() !== $fullyQualifiedName; } return \false; } diff --git a/src/Application/FileProcessor/PhpFileProcessor.php b/src/Application/FileProcessor/PhpFileProcessor.php index 5a110e738c3..8bbe9e3cd77 100644 --- a/src/Application/FileProcessor/PhpFileProcessor.php +++ b/src/Application/FileProcessor/PhpFileProcessor.php @@ -94,23 +94,36 @@ final class PhpFileProcessor implements FileProcessorInterface $systemErrorsAndFileDiffs[Bridge::SYSTEM_ERRORS] = $parsingSystemErrors; return $systemErrorsAndFileDiffs; } + $hasChangedOnPostRector = \false; // 2. change nodes with Rectors do { $file->changeHasChanged(\false); $this->fileProcessor->refactor($file, $configuration); + $fileNewStmts = $file->getNewStmts(); // 3. apply post rectors - $newStmts = $this->postFileProcessor->traverse($file->getNewStmts()); + $filePostRectorNewStmts = $this->postFileProcessor->traverse($fileNewStmts); // this is needed for new tokens added in "afterTraverse()" - $file->changeNewStmts($newStmts); + $file->changeNewStmts($filePostRectorNewStmts); + if ($file->getRectorWithLineChanges() === [] && $fileNewStmts !== $filePostRectorNewStmts) { + $hasChangedOnPostRector = \true; + } // 4. print to file or string // important to detect if file has changed $this->printFile($file, $configuration); } while ($file->hasChanged()); - // return json here + // return early on no diff $fileDiff = $file->getFileDiff(); if (!$fileDiff instanceof FileDiff) { return $systemErrorsAndFileDiffs; } + // No Line change and no PostRector change? return early + if ($file->getRectorWithLineChanges() === [] && !$hasChangedOnPostRector) { + return $systemErrorsAndFileDiffs; + } + // return early on diff is empty + if ($fileDiff->getDiff() === '') { + return $systemErrorsAndFileDiffs; + } $systemErrorsAndFileDiffs[Bridge::FILE_DIFFS] = [$fileDiff]; return $systemErrorsAndFileDiffs; } diff --git a/src/Application/VersionResolver.php b/src/Application/VersionResolver.php index 2e62f30c411..1f977da18b5 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 = '4a583b6a777b38f14791374a8793f37ae024e6f9'; + public const PACKAGE_VERSION = '48e97cb0e710d6b7d704d31a6e3c4320486e1ed4'; /** * @api * @var string */ - public const RELEASE_DATE = '2023-02-23 09:36:23'; + public const RELEASE_DATE = '2023-02-23 17:27:19'; /** * @var int */ diff --git a/vendor/autoload.php b/vendor/autoload.php index 46a6782cbfb..81aeee572f1 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 ComposerAutoloaderInita0036db571e6f3784692d7da179c45bf::getLoader(); +return ComposerAutoloaderInitaad712e8abc73da9ea9e94ef09ebace2::getLoader(); diff --git a/vendor/composer/autoload_real.php b/vendor/composer/autoload_real.php index f47459a4b3b..2e0aef599ea 100644 --- a/vendor/composer/autoload_real.php +++ b/vendor/composer/autoload_real.php @@ -2,7 +2,7 @@ // autoload_real.php @generated by Composer -class ComposerAutoloaderInita0036db571e6f3784692d7da179c45bf +class ComposerAutoloaderInitaad712e8abc73da9ea9e94ef09ebace2 { private static $loader; @@ -22,17 +22,17 @@ class ComposerAutoloaderInita0036db571e6f3784692d7da179c45bf return self::$loader; } - spl_autoload_register(array('ComposerAutoloaderInita0036db571e6f3784692d7da179c45bf', 'loadClassLoader'), true, true); + spl_autoload_register(array('ComposerAutoloaderInitaad712e8abc73da9ea9e94ef09ebace2', 'loadClassLoader'), true, true); self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__)); - spl_autoload_unregister(array('ComposerAutoloaderInita0036db571e6f3784692d7da179c45bf', 'loadClassLoader')); + spl_autoload_unregister(array('ComposerAutoloaderInitaad712e8abc73da9ea9e94ef09ebace2', 'loadClassLoader')); require __DIR__ . '/autoload_static.php'; - call_user_func(\Composer\Autoload\ComposerStaticInita0036db571e6f3784692d7da179c45bf::getInitializer($loader)); + call_user_func(\Composer\Autoload\ComposerStaticInitaad712e8abc73da9ea9e94ef09ebace2::getInitializer($loader)); $loader->setClassMapAuthoritative(true); $loader->register(true); - $filesToLoad = \Composer\Autoload\ComposerStaticInita0036db571e6f3784692d7da179c45bf::$files; + $filesToLoad = \Composer\Autoload\ComposerStaticInitaad712e8abc73da9ea9e94ef09ebace2::$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 aef66999a99..1ac99675062 100644 --- a/vendor/composer/autoload_static.php +++ b/vendor/composer/autoload_static.php @@ -4,7 +4,7 @@ namespace Composer\Autoload; -class ComposerStaticInita0036db571e6f3784692d7da179c45bf +class ComposerStaticInitaad712e8abc73da9ea9e94ef09ebace2 { public static $files = array ( 'ad155f8f1cf0d418fe49e248db8c661b' => __DIR__ . '/..' . '/react/promise/src/functions_include.php', @@ -3126,9 +3126,9 @@ class ComposerStaticInita0036db571e6f3784692d7da179c45bf public static function getInitializer(ClassLoader $loader) { return \Closure::bind(function () use ($loader) { - $loader->prefixLengthsPsr4 = ComposerStaticInita0036db571e6f3784692d7da179c45bf::$prefixLengthsPsr4; - $loader->prefixDirsPsr4 = ComposerStaticInita0036db571e6f3784692d7da179c45bf::$prefixDirsPsr4; - $loader->classMap = ComposerStaticInita0036db571e6f3784692d7da179c45bf::$classMap; + $loader->prefixLengthsPsr4 = ComposerStaticInitaad712e8abc73da9ea9e94ef09ebace2::$prefixLengthsPsr4; + $loader->prefixDirsPsr4 = ComposerStaticInitaad712e8abc73da9ea9e94ef09ebace2::$prefixDirsPsr4; + $loader->classMap = ComposerStaticInitaad712e8abc73da9ea9e94ef09ebace2::$classMap; }, null, ClassLoader::class); }