mirror of
https://github.com/rectorphp/rector.git
synced 2025-01-17 21:38:22 +01:00
Updated Rector to commit e77f6d21a97319f57f11a7e6eae9b583fe425c1e
e77f6d21a9
[ApplicationFileProcessor] Refactor ApplicationFileProcessor to filter file paths early before run both parallel and non-parallel (#4519)
This commit is contained in:
parent
d67f0e438d
commit
9965650f0e
@ -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
|
||||
|
@ -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 {
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
*/
|
||||
|
@ -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);
|
||||
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
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 ComposerAutoloaderInit3839209d140a2de4719468db39400ec4::getLoader();
|
||||
return ComposerAutoloaderInit39d1f21f0961349af70a1323053c942a::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 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;
|
||||
|
8
vendor/composer/autoload_static.php
vendored
8
vendor/composer/autoload_static.php
vendored
@ -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);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user