From 9965650f0e0953fb3d3bcc98c52b9721b21c3402 Mon Sep 17 00:00:00 2001 From: Tomas Votruba Date: Sat, 15 Jul 2023 00:49:23 +0000 Subject: [PATCH] Updated Rector to commit e77f6d21a97319f57f11a7e6eae9b583fe425c1e https://github.com/rectorphp/rector-src/commit/e77f6d21a97319f57f11a7e6eae9b583fe425c1e [ApplicationFileProcessor] Refactor ApplicationFileProcessor to filter file paths early before run both parallel and non-parallel (#4519) --- .../Output/ConsoleOutputFormatter.php | 10 ++-------- packages/Parallel/WorkerRunner.php | 12 ++++++------ src/Application/ApplicationFileProcessor.php | 11 +++++------ src/Application/VersionResolver.php | 4 ++-- src/Console/Output/RectorOutputStyle.php | 4 ---- src/Console/Style/RectorConsoleOutputStyle.php | 9 --------- src/Contract/Console/OutputStyleInterface.php | 1 - vendor/autoload.php | 2 +- vendor/composer/autoload_real.php | 10 +++++----- vendor/composer/autoload_static.php | 8 ++++---- 10 files changed, 25 insertions(+), 46 deletions(-) diff --git a/packages/ChangesReporting/Output/ConsoleOutputFormatter.php b/packages/ChangesReporting/Output/ConsoleOutputFormatter.php index bbc4ad14266..e3f0daea6ba 100644 --- a/packages/ChangesReporting/Output/ConsoleOutputFormatter.php +++ b/packages/ChangesReporting/Output/ConsoleOutputFormatter.php @@ -39,17 +39,11 @@ final class ConsoleOutputFormatter implements OutputFormatterInterface } public function report(ProcessResult $processResult, Configuration $configuration) : void { - $errors = $processResult->getErrors(); - // only show 100% when no errors - if ($errors === [] && $configuration->shouldShowProgressBar()) { - $this->rectorOutputStyle->progressFinish(); - } - // show diff after progress bar if ($configuration->shouldShowDiffs()) { $this->reportFileDiffs($processResult->getFileDiffs()); } - $this->reportErrors($errors); - if ($errors !== []) { + $this->reportErrors($processResult->getErrors()); + if ($processResult->getErrors() !== []) { return; } // to keep space between progress bar and success message diff --git a/packages/Parallel/WorkerRunner.php b/packages/Parallel/WorkerRunner.php index ad3adf9e07c..ae3ce1a164b 100644 --- a/packages/Parallel/WorkerRunner.php +++ b/packages/Parallel/WorkerRunner.php @@ -6,8 +6,8 @@ namespace Rector\Parallel; use RectorPrefix202307\Clue\React\NDJson\Decoder; use RectorPrefix202307\Clue\React\NDJson\Encoder; use RectorPrefix202307\Nette\Utils\FileSystem; +use PHPStan\Analyser\NodeScopeResolver; use Rector\Caching\Detector\ChangedFilesDetector; -use Rector\Core\Application\ApplicationFileProcessor; use Rector\Core\Console\Style\RectorConsoleOutputStyle; use Rector\Core\Contract\Processor\FileProcessorInterface; use Rector\Core\Provider\CurrentFileProvider; @@ -46,9 +46,9 @@ final class WorkerRunner private $rectorConsoleOutputStyle; /** * @readonly - * @var \Rector\Core\Application\ApplicationFileProcessor + * @var \PHPStan\Analyser\NodeScopeResolver */ - private $applicationFileProcessor; + private $nodeScopeResolver; /** * @readonly * @var \Rector\Caching\Detector\ChangedFilesDetector @@ -66,13 +66,13 @@ final class WorkerRunner /** * @param FileProcessorInterface[] $fileProcessors */ - public function __construct(ArrayParametersMerger $arrayParametersMerger, CurrentFileProvider $currentFileProvider, DynamicSourceLocatorDecorator $dynamicSourceLocatorDecorator, RectorConsoleOutputStyle $rectorConsoleOutputStyle, ApplicationFileProcessor $applicationFileProcessor, ChangedFilesDetector $changedFilesDetector, iterable $fileProcessors = []) + public function __construct(ArrayParametersMerger $arrayParametersMerger, CurrentFileProvider $currentFileProvider, DynamicSourceLocatorDecorator $dynamicSourceLocatorDecorator, RectorConsoleOutputStyle $rectorConsoleOutputStyle, NodeScopeResolver $nodeScopeResolver, ChangedFilesDetector $changedFilesDetector, iterable $fileProcessors = []) { $this->arrayParametersMerger = $arrayParametersMerger; $this->currentFileProvider = $currentFileProvider; $this->dynamicSourceLocatorDecorator = $dynamicSourceLocatorDecorator; $this->rectorConsoleOutputStyle = $rectorConsoleOutputStyle; - $this->applicationFileProcessor = $applicationFileProcessor; + $this->nodeScopeResolver = $nodeScopeResolver; $this->changedFilesDetector = $changedFilesDetector; $this->fileProcessors = $fileProcessors; } @@ -98,7 +98,7 @@ final class WorkerRunner $errorAndFileDiffs = []; $systemErrors = []; // 1. allow PHPStan to work with static reflection on provided files - $filePaths = $this->applicationFileProcessor->configurePHPStanNodeScopeResolver($filePaths, $configuration); + $this->nodeScopeResolver->setAnalysedFiles($filePaths); foreach ($filePaths as $filePath) { $file = null; try { diff --git a/src/Application/ApplicationFileProcessor.php b/src/Application/ApplicationFileProcessor.php index ffbb5449eb0..6e29e879a4c 100644 --- a/src/Application/ApplicationFileProcessor.php +++ b/src/Application/ApplicationFileProcessor.php @@ -116,11 +116,12 @@ final class ApplicationFileProcessor return [Bridge::SYSTEM_ERRORS => [], Bridge::FILE_DIFFS => []]; } $this->configureCustomErrorHandler(); + $filePaths = $this->resolveFilePathsByConfigurationFileExtensions($filePaths, $configuration); if ($configuration->isParallel()) { $systemErrorsAndFileDiffs = $this->runParallel($filePaths, $configuration, $input); } else { - // 1. PHPStan has to know about all files too - $filePaths = $this->configurePHPStanNodeScopeResolver($filePaths, $configuration); + // 1. allow PHPStan to work with static reflection on provided files + $this->nodeScopeResolver->setAnalysedFiles($filePaths); // 2. collect all files from files+dirs provided filtered paths $files = $this->fileFactory->createFromPaths($filePaths); $systemErrorsAndFileDiffs = $this->processFiles($files, $configuration); @@ -172,16 +173,14 @@ final class ApplicationFileProcessor * @param string[] $filePaths * @return string[] */ - public function configurePHPStanNodeScopeResolver(array $filePaths, Configuration $configuration) : array + public function resolveFilePathsByConfigurationFileExtensions(array $filePaths, Configuration $configuration) : array { $fileExtensions = $configuration->getFileExtensions(); $fileWithExtensionsFilter = static function (string $filePath) use($fileExtensions) : bool { $filePathExtension = \pathinfo($filePath, \PATHINFO_EXTENSION); return \in_array($filePathExtension, $fileExtensions, \true); }; - $filePaths = \array_filter($filePaths, $fileWithExtensionsFilter); - $this->nodeScopeResolver->setAnalysedFiles($filePaths); - return $filePaths; + return \array_filter($filePaths, $fileWithExtensionsFilter); } /** * @param File[] $files diff --git a/src/Application/VersionResolver.php b/src/Application/VersionResolver.php index 1fc7ddff622..c71928f1395 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 = '9217e0da232258fecb049c6a08d165ebe70aa36b'; + public const PACKAGE_VERSION = 'e77f6d21a97319f57f11a7e6eae9b583fe425c1e'; /** * @api * @var string */ - public const RELEASE_DATE = '2023-07-14 20:03:51'; + public const RELEASE_DATE = '2023-07-15 07:45:34'; /** * @var int */ diff --git a/src/Console/Output/RectorOutputStyle.php b/src/Console/Output/RectorOutputStyle.php index 94d94230b1c..817f5f4d5dd 100644 --- a/src/Console/Output/RectorOutputStyle.php +++ b/src/Console/Output/RectorOutputStyle.php @@ -28,10 +28,6 @@ final class RectorOutputStyle implements OutputStyleInterface { $this->rectorConsoleOutputStyle->progressAdvance($step); } - public function progressFinish() : void - { - $this->rectorConsoleOutputStyle->progressFinish(); - } public function error(string $message) : void { $this->rectorConsoleOutputStyle->error($message); diff --git a/src/Console/Style/RectorConsoleOutputStyle.php b/src/Console/Style/RectorConsoleOutputStyle.php index 416783e9a61..52ecacff3ff 100644 --- a/src/Console/Style/RectorConsoleOutputStyle.php +++ b/src/Console/Style/RectorConsoleOutputStyle.php @@ -75,13 +75,4 @@ final class RectorConsoleOutputStyle extends SymfonyStyle } return $this->progressBar; } - public function progressFinish() : void - { - // hide progress bar in tests - if (\defined('PHPUNIT_COMPOSER_INSTALL')) { - return; - } - $progressBar = $this->getProgressBar(); - $progressBar->finish(); - } } diff --git a/src/Contract/Console/OutputStyleInterface.php b/src/Contract/Console/OutputStyleInterface.php index 91ace63a872..fe569fb798a 100644 --- a/src/Contract/Console/OutputStyleInterface.php +++ b/src/Contract/Console/OutputStyleInterface.php @@ -21,5 +21,4 @@ interface OutputStyleInterface public function setVerbosity(int $level) : void; public function progressStart(int $fileCount) : void; public function progressAdvance(int $step = 1) : void; - public function progressFinish() : void; } diff --git a/vendor/autoload.php b/vendor/autoload.php index 719057870c8..3a582cc2c94 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 ComposerAutoloaderInit3839209d140a2de4719468db39400ec4::getLoader(); +return ComposerAutoloaderInit39d1f21f0961349af70a1323053c942a::getLoader(); diff --git a/vendor/composer/autoload_real.php b/vendor/composer/autoload_real.php index 62e3d44a24b..3fa297132e1 100644 --- a/vendor/composer/autoload_real.php +++ b/vendor/composer/autoload_real.php @@ -2,7 +2,7 @@ // autoload_real.php @generated by Composer -class ComposerAutoloaderInit3839209d140a2de4719468db39400ec4 +class ComposerAutoloaderInit39d1f21f0961349af70a1323053c942a { private static $loader; @@ -22,17 +22,17 @@ class ComposerAutoloaderInit3839209d140a2de4719468db39400ec4 return self::$loader; } - spl_autoload_register(array('ComposerAutoloaderInit3839209d140a2de4719468db39400ec4', 'loadClassLoader'), true, true); + spl_autoload_register(array('ComposerAutoloaderInit39d1f21f0961349af70a1323053c942a', 'loadClassLoader'), true, true); self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__)); - spl_autoload_unregister(array('ComposerAutoloaderInit3839209d140a2de4719468db39400ec4', 'loadClassLoader')); + spl_autoload_unregister(array('ComposerAutoloaderInit39d1f21f0961349af70a1323053c942a', 'loadClassLoader')); require __DIR__ . '/autoload_static.php'; - call_user_func(\Composer\Autoload\ComposerStaticInit3839209d140a2de4719468db39400ec4::getInitializer($loader)); + call_user_func(\Composer\Autoload\ComposerStaticInit39d1f21f0961349af70a1323053c942a::getInitializer($loader)); $loader->setClassMapAuthoritative(true); $loader->register(true); - $filesToLoad = \Composer\Autoload\ComposerStaticInit3839209d140a2de4719468db39400ec4::$files; + $filesToLoad = \Composer\Autoload\ComposerStaticInit39d1f21f0961349af70a1323053c942a::$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 f78a9737ce7..e8f58874367 100644 --- a/vendor/composer/autoload_static.php +++ b/vendor/composer/autoload_static.php @@ -4,7 +4,7 @@ namespace Composer\Autoload; -class ComposerStaticInit3839209d140a2de4719468db39400ec4 +class ComposerStaticInit39d1f21f0961349af70a1323053c942a { public static $files = array ( 'ad155f8f1cf0d418fe49e248db8c661b' => __DIR__ . '/..' . '/react/promise/src/functions_include.php', @@ -3028,9 +3028,9 @@ class ComposerStaticInit3839209d140a2de4719468db39400ec4 public static function getInitializer(ClassLoader $loader) { return \Closure::bind(function () use ($loader) { - $loader->prefixLengthsPsr4 = ComposerStaticInit3839209d140a2de4719468db39400ec4::$prefixLengthsPsr4; - $loader->prefixDirsPsr4 = ComposerStaticInit3839209d140a2de4719468db39400ec4::$prefixDirsPsr4; - $loader->classMap = ComposerStaticInit3839209d140a2de4719468db39400ec4::$classMap; + $loader->prefixLengthsPsr4 = ComposerStaticInit39d1f21f0961349af70a1323053c942a::$prefixLengthsPsr4; + $loader->prefixDirsPsr4 = ComposerStaticInit39d1f21f0961349af70a1323053c942a::$prefixDirsPsr4; + $loader->classMap = ComposerStaticInit39d1f21f0961349af70a1323053c942a::$classMap; }, null, ClassLoader::class); }