Updated Rector to commit 972d7607f1c4ab8b733b91d7aa5020ce1b143538

972d7607f1 [Application] Merge process files on both parallel and non-parallel process (#4523)
This commit is contained in:
Tomas Votruba 2023-07-19 10:53:43 +00:00
parent 8d3877fbc0
commit b9ed01d3be
15 changed files with 95 additions and 239 deletions

View File

@ -61,7 +61,6 @@ use Rector\NodeTypeResolver\PHPStan\Scope\Contract\NodeVisitor\ScopeResolverNode
use Rector\NodeTypeResolver\PHPStan\Scope\PHPStanNodeScopeResolver;
use Rector\NodeTypeResolver\Reflection\BetterReflection\SourceLocator\IntermediateSourceLocator;
use Rector\NodeTypeResolver\Reflection\BetterReflection\SourceLocatorProvider\DynamicSourceLocatorProvider;
use Rector\Parallel\WorkerRunner;
use Rector\PhpAttribute\AnnotationToAttributeMapper;
use Rector\PhpAttribute\Contract\AnnotationToAttributeMapperInterface;
use Rector\PhpDocParser\NodeTraverser\SimpleCallableNodeTraverser;
@ -200,6 +199,5 @@ return static function (RectorConfig $rectorConfig) : void {
$services->set(NodeNameResolver::class)->arg('$nodeNameResolvers', tagged_iterator(NodeNameResolverInterface::class));
$services->set(ApplicationFileProcessor::class)->arg('$fileProcessors', tagged_iterator(FileProcessorInterface::class));
$services->set(FileFactory::class)->arg('$fileProcessors', tagged_iterator(FileProcessorInterface::class));
$services->set(WorkerRunner::class)->arg('$fileProcessors', tagged_iterator(FileProcessorInterface::class));
$services->set(AnnotationToAttributeMapper::class)->arg('$annotationToAttributeMappers', tagged_iterator(AnnotationToAttributeMapperInterface::class));
};

View File

@ -5,18 +5,11 @@ 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\Console\Style\RectorConsoleOutputStyle;
use Rector\Core\Contract\Processor\FileProcessorInterface;
use Rector\Core\Provider\CurrentFileProvider;
use Rector\Core\Application\ApplicationFileProcessor;
use Rector\Core\StaticReflection\DynamicSourceLocatorDecorator;
use Rector\Core\Util\ArrayParametersMerger;
use Rector\Core\ValueObject\Application\File;
use Rector\Core\ValueObject\Configuration;
use Rector\Core\ValueObject\Error\SystemError;
use Rector\Core\ValueObject\Reporting\FileDiff;
use Rector\Parallel\ValueObject\Bridge;
use RectorPrefix202307\Symplify\EasyParallel\Enum\Action;
use RectorPrefix202307\Symplify\EasyParallel\Enum\ReactCommand;
@ -24,16 +17,6 @@ use RectorPrefix202307\Symplify\EasyParallel\Enum\ReactEvent;
use Throwable;
final class WorkerRunner
{
/**
* @readonly
* @var \Rector\Core\Util\ArrayParametersMerger
*/
private $arrayParametersMerger;
/**
* @readonly
* @var \Rector\Core\Provider\CurrentFileProvider
*/
private $currentFileProvider;
/**
* @readonly
* @var \Rector\Core\StaticReflection\DynamicSourceLocatorDecorator
@ -41,48 +24,31 @@ final class WorkerRunner
private $dynamicSourceLocatorDecorator;
/**
* @readonly
* @var \Rector\Core\Console\Style\RectorConsoleOutputStyle
* @var \Rector\Core\Application\ApplicationFileProcessor
*/
private $rectorConsoleOutputStyle;
private $applicationFileProcessor;
/**
* @readonly
* @var \PHPStan\Analyser\NodeScopeResolver
*/
private $nodeScopeResolver;
/**
* @readonly
* @var \Rector\Caching\Detector\ChangedFilesDetector
*/
private $changedFilesDetector;
/**
* @var FileProcessorInterface[]
* @readonly
*/
private $fileProcessors = [];
/**
* @var string
*/
private const RESULT = 'result';
/**
* @param FileProcessorInterface[] $fileProcessors
*/
public function __construct(ArrayParametersMerger $arrayParametersMerger, CurrentFileProvider $currentFileProvider, DynamicSourceLocatorDecorator $dynamicSourceLocatorDecorator, RectorConsoleOutputStyle $rectorConsoleOutputStyle, NodeScopeResolver $nodeScopeResolver, ChangedFilesDetector $changedFilesDetector, iterable $fileProcessors = [])
public function __construct(DynamicSourceLocatorDecorator $dynamicSourceLocatorDecorator, ApplicationFileProcessor $applicationFileProcessor, NodeScopeResolver $nodeScopeResolver)
{
$this->arrayParametersMerger = $arrayParametersMerger;
$this->currentFileProvider = $currentFileProvider;
$this->dynamicSourceLocatorDecorator = $dynamicSourceLocatorDecorator;
$this->rectorConsoleOutputStyle = $rectorConsoleOutputStyle;
$this->applicationFileProcessor = $applicationFileProcessor;
$this->nodeScopeResolver = $nodeScopeResolver;
$this->changedFilesDetector = $changedFilesDetector;
$this->fileProcessors = $fileProcessors;
}
public function run(Encoder $encoder, Decoder $decoder, Configuration $configuration) : void
{
$this->dynamicSourceLocatorDecorator->addPaths($configuration->getPaths());
// 1. handle system error
$handleErrorCallback = static function (Throwable $throwable) use($encoder) : void {
$systemErrors = new SystemError($throwable->getMessage(), $throwable->getFile(), $throwable->getLine());
$encoder->write([ReactCommand::ACTION => Action::RESULT, self::RESULT => [Bridge::SYSTEM_ERRORS => [$systemErrors], Bridge::FILES_COUNT => 0, Bridge::SYSTEM_ERRORS_COUNT => 1]]);
$systemError = new SystemError($throwable->getMessage(), $throwable->getFile(), $throwable->getLine());
$encoder->write([ReactCommand::ACTION => Action::RESULT, self::RESULT => [Bridge::SYSTEM_ERRORS => [$systemError], Bridge::FILES_COUNT => 0, Bridge::SYSTEM_ERRORS_COUNT => 1]]);
$encoder->end();
};
$encoder->on(ReactEvent::ERROR, $handleErrorCallback);
@ -92,72 +58,16 @@ final class WorkerRunner
if ($action !== Action::MAIN) {
return;
}
$systemErrorsCount = 0;
/** @var string[] $filePaths */
$filePaths = $json[Bridge::FILES] ?? [];
$errorAndFileDiffs = [];
$systemErrors = [];
// 1. allow PHPStan to work with static reflection on provided files
$this->nodeScopeResolver->setAnalysedFiles($filePaths);
foreach ($filePaths as $filePath) {
$file = null;
try {
$file = new File($filePath, FileSystem::read($filePath));
$this->currentFileProvider->setFile($file);
$errorAndFileDiffs = $this->processFile($file, $configuration, $errorAndFileDiffs);
if ($errorAndFileDiffs[Bridge::SYSTEM_ERRORS] !== []) {
$this->invalidateFile($file);
} elseif (!$configuration->isDryRun() || $errorAndFileDiffs[Bridge::FILE_DIFFS] === []) {
$this->changedFilesDetector->cacheFileWithDependencies($file->getFilePath());
}
} catch (Throwable $throwable) {
++$systemErrorsCount;
$systemErrors = $this->collectSystemErrors($systemErrors, $throwable, $filePath);
$this->invalidateFile($file);
}
}
$systemErrorsAndFileDiffs = $this->applicationFileProcessor->processFiles($filePaths, $configuration);
/**
* this invokes all listeners listening $decoder->on(...) @see \Symplify\EasyParallel\Enum\ReactEvent::DATA
*/
$encoder->write([ReactCommand::ACTION => Action::RESULT, self::RESULT => [Bridge::FILE_DIFFS => $errorAndFileDiffs[Bridge::FILE_DIFFS] ?? [], Bridge::FILES_COUNT => \count($filePaths), Bridge::SYSTEM_ERRORS => $systemErrors, Bridge::SYSTEM_ERRORS_COUNT => $systemErrorsCount]]);
$encoder->write([ReactCommand::ACTION => Action::RESULT, self::RESULT => [Bridge::FILE_DIFFS => $systemErrorsAndFileDiffs[Bridge::FILE_DIFFS], Bridge::FILES_COUNT => \count($filePaths), Bridge::SYSTEM_ERRORS => $systemErrorsAndFileDiffs[Bridge::SYSTEM_ERRORS], Bridge::SYSTEM_ERRORS_COUNT => $systemErrorsAndFileDiffs[Bridge::SYSTEM_ERRORS_COUNT]]]);
});
$decoder->on(ReactEvent::ERROR, $handleErrorCallback);
}
/**
* @param array{system_errors: SystemError[], file_diffs: FileDiff[]}|mixed[] $errorAndFileDiffs
* @return array{system_errors: SystemError[], file_diffs: FileDiff[]}
*/
private function processFile(File $file, Configuration $configuration, array $errorAndFileDiffs) : array
{
foreach ($this->fileProcessors as $fileProcessor) {
if (!$fileProcessor->supports($file, $configuration)) {
continue;
}
$currentErrorsAndFileDiffs = $fileProcessor->process($file, $configuration);
$errorAndFileDiffs = $this->arrayParametersMerger->merge($errorAndFileDiffs, $currentErrorsAndFileDiffs);
}
return $errorAndFileDiffs;
}
/**
* @param SystemError[] $systemErrors
* @return SystemError[]
*/
private function collectSystemErrors(array $systemErrors, Throwable $throwable, string $filePath) : array
{
$errorMessage = \sprintf('System error: "%s"', $throwable->getMessage()) . \PHP_EOL;
if ($this->rectorConsoleOutputStyle->isDebug()) {
$systemErrors[] = new SystemError($errorMessage . \PHP_EOL . 'Stack trace:' . \PHP_EOL . $throwable->getTraceAsString(), $filePath, $throwable->getLine());
return $systemErrors;
}
$errorMessage .= 'Run Rector with "--debug" option and post the report here: https://github.com/rectorphp/rector/issues/new';
$systemErrors[] = new SystemError($errorMessage, $filePath, $throwable->getLine());
return $systemErrors;
}
private function invalidateFile(?File $file) : void
{
if (!$file instanceof File) {
return;
}
$this->changedFilesDetector->invalidateFile($file->getFilePath());
}
}

View File

@ -3,13 +3,14 @@
declare (strict_types=1);
namespace Rector\Core\Application;
use RectorPrefix202307\Nette\Utils\FileSystem as UtilsFileSystem;
use PHPStan\Analyser\NodeScopeResolver;
use Rector\Caching\Detector\ChangedFilesDetector;
use Rector\Core\Application\FileDecorator\FileDiffFileDecorator;
use Rector\Core\Configuration\Option;
use Rector\Core\Configuration\Parameter\SimpleParameterProvider;
use Rector\Core\Contract\Console\OutputStyleInterface;
use Rector\Core\Contract\Processor\FileProcessorInterface;
use Rector\Core\Provider\CurrentFileProvider;
use Rector\Core\Util\ArrayParametersMerger;
use Rector\Core\ValueObject\Application\File;
use Rector\Core\ValueObject\Configuration;
@ -18,23 +19,14 @@ use Rector\Core\ValueObject\Reporting\FileDiff;
use Rector\Core\ValueObjectFactory\Application\FileFactory;
use Rector\Parallel\Application\ParallelFileProcessor;
use Rector\Parallel\ValueObject\Bridge;
use Rector\Testing\PHPUnit\StaticPHPUnitEnvironment;
use RectorPrefix202307\Symfony\Component\Console\Input\InputInterface;
use RectorPrefix202307\Symfony\Component\Filesystem\Filesystem;
use RectorPrefix202307\Symplify\EasyParallel\CpuCoreCountProvider;
use RectorPrefix202307\Symplify\EasyParallel\Exception\ParallelShouldNotHappenException;
use RectorPrefix202307\Symplify\EasyParallel\ScheduleFactory;
use Throwable;
final class ApplicationFileProcessor
{
/**
* @readonly
* @var \Symfony\Component\Filesystem\Filesystem
*/
private $filesystem;
/**
* @readonly
* @var \Rector\Core\Application\FileDecorator\FileDiffFileDecorator
*/
private $fileDiffFileDecorator;
/**
* @readonly
* @var \Rector\Core\Contract\Console\OutputStyleInterface
@ -75,6 +67,11 @@ final class ApplicationFileProcessor
* @var \Rector\Caching\Detector\ChangedFilesDetector
*/
private $changedFilesDetector;
/**
* @readonly
* @var \Rector\Core\Provider\CurrentFileProvider
*/
private $currentFileProvider;
/**
* @var FileProcessorInterface[]
* @readonly
@ -91,10 +88,8 @@ final class ApplicationFileProcessor
/**
* @param FileProcessorInterface[] $fileProcessors
*/
public function __construct(Filesystem $filesystem, FileDiffFileDecorator $fileDiffFileDecorator, OutputStyleInterface $rectorOutputStyle, FileFactory $fileFactory, NodeScopeResolver $nodeScopeResolver, ArrayParametersMerger $arrayParametersMerger, ParallelFileProcessor $parallelFileProcessor, ScheduleFactory $scheduleFactory, CpuCoreCountProvider $cpuCoreCountProvider, ChangedFilesDetector $changedFilesDetector, iterable $fileProcessors)
public function __construct(OutputStyleInterface $rectorOutputStyle, FileFactory $fileFactory, NodeScopeResolver $nodeScopeResolver, ArrayParametersMerger $arrayParametersMerger, ParallelFileProcessor $parallelFileProcessor, ScheduleFactory $scheduleFactory, CpuCoreCountProvider $cpuCoreCountProvider, ChangedFilesDetector $changedFilesDetector, CurrentFileProvider $currentFileProvider, iterable $fileProcessors)
{
$this->filesystem = $filesystem;
$this->fileDiffFileDecorator = $fileDiffFileDecorator;
$this->rectorOutputStyle = $rectorOutputStyle;
$this->fileFactory = $fileFactory;
$this->nodeScopeResolver = $nodeScopeResolver;
@ -103,6 +98,7 @@ final class ApplicationFileProcessor
$this->scheduleFactory = $scheduleFactory;
$this->cpuCoreCountProvider = $cpuCoreCountProvider;
$this->changedFilesDetector = $changedFilesDetector;
$this->currentFileProvider = $currentFileProvider;
$this->fileProcessors = $fileProcessors;
}
/**
@ -121,74 +117,86 @@ final class ApplicationFileProcessor
} else {
// 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);
if ($configuration->shouldShowDiffs()) {
$this->fileDiffFileDecorator->decorate($files);
}
$this->printFiles($files, $configuration);
$systemErrorsAndFileDiffs = $this->processFiles($filePaths, $configuration, \false);
}
$systemErrorsAndFileDiffs[Bridge::SYSTEM_ERRORS] = \array_merge($systemErrorsAndFileDiffs[Bridge::SYSTEM_ERRORS], $this->systemErrors);
$this->restoreErrorHandler();
return $systemErrorsAndFileDiffs;
}
/**
* @api use only for tests
*
* @param File[] $files
* @return array{system_errors: SystemError[], file_diffs: FileDiff[]}
* @param string[]|File[] $filePaths
* @return array{system_errors: SystemError[], file_diffs: FileDiff[], system_errors_count: int}
*/
public function processFiles(array $files, Configuration $configuration) : array
public function processFiles(array $filePaths, Configuration $configuration, bool $isParallel = \true) : array
{
$shouldShowProgressBar = $configuration->shouldShowProgressBar();
if ($shouldShowProgressBar) {
$fileCount = \count($files);
// progress bar on parallel handled on runParallel()
if (!$isParallel && $shouldShowProgressBar) {
$fileCount = \count($filePaths);
$this->rectorOutputStyle->progressStart($fileCount);
$this->rectorOutputStyle->progressAdvance(0);
}
$systemErrorsAndFileDiffs = [Bridge::SYSTEM_ERRORS => [], Bridge::FILE_DIFFS => []];
foreach ($files as $file) {
foreach ($this->fileProcessors as $fileProcessor) {
if (!$fileProcessor->supports($file, $configuration)) {
continue;
$systemErrorsAndFileDiffs = [Bridge::SYSTEM_ERRORS => [], Bridge::FILE_DIFFS => [], Bridge::SYSTEM_ERRORS_COUNT => 0];
foreach ($filePaths as $filePath) {
$file = null;
try {
$file = $filePath instanceof File ? $filePath : new File($filePath, UtilsFileSystem::read($filePath));
$systemErrorsAndFileDiffs = $this->processFile($file, $systemErrorsAndFileDiffs, $configuration);
// progress bar +1,
// progress bar on parallel handled on runParallel()
if (!$isParallel && $shouldShowProgressBar) {
$this->rectorOutputStyle->progressAdvance();
}
$result = $fileProcessor->process($file, $configuration);
$systemErrorsAndFileDiffs = $this->arrayParametersMerger->merge($systemErrorsAndFileDiffs, $result);
}
if ($systemErrorsAndFileDiffs[Bridge::SYSTEM_ERRORS] !== []) {
$this->changedFilesDetector->invalidateFile($file->getFilePath());
} elseif (!$configuration->isDryRun() || $systemErrorsAndFileDiffs[Bridge::FILE_DIFFS] === []) {
$this->changedFilesDetector->cacheFileWithDependencies($file->getFilePath());
}
// progress bar +1
if ($shouldShowProgressBar) {
$this->rectorOutputStyle->progressAdvance();
} catch (Throwable $throwable) {
$this->invalidateFile($file);
if (StaticPHPUnitEnvironment::isPHPUnitRun()) {
throw $throwable;
}
$systemErrorsAndFileDiffs[Bridge::SYSTEM_ERRORS][] = $this->resolveSystemError($throwable, $filePath);
}
}
return $systemErrorsAndFileDiffs;
}
/**
* @param File[] $files
* @param array{system_errors: SystemError[], file_diffs: FileDiff[], system_errors_count: int} $systemErrorsAndFileDiffs
* @return array{system_errors: SystemError[], file_diffs: FileDiff[], system_errors_count: int}
*/
private function printFiles(array $files, Configuration $configuration) : void
private function processFile(File $file, array $systemErrorsAndFileDiffs, Configuration $configuration) : array
{
if ($configuration->isDryRun()) {
return;
}
foreach ($files as $file) {
if (!$file->hasChanged()) {
$this->currentFileProvider->setFile($file);
foreach ($this->fileProcessors as $fileProcessor) {
if (!$fileProcessor->supports($file, $configuration)) {
continue;
}
$this->printFile($file);
$result = $fileProcessor->process($file, $configuration);
$systemErrorsAndFileDiffs = $this->arrayParametersMerger->merge($systemErrorsAndFileDiffs, $result);
}
if ($systemErrorsAndFileDiffs[Bridge::SYSTEM_ERRORS] !== []) {
$this->changedFilesDetector->invalidateFile($file->getFilePath());
} elseif (!$configuration->isDryRun() || $systemErrorsAndFileDiffs[Bridge::FILE_DIFFS] === []) {
$this->changedFilesDetector->cacheFileWithDependencies($file->getFilePath());
}
return $systemErrorsAndFileDiffs;
}
private function printFile(File $file) : void
/**
* @param string|\Rector\Core\ValueObject\Application\File $filePath
*/
private function resolveSystemError(Throwable $throwable, $filePath) : SystemError
{
$filePath = $file->getFilePath();
$this->filesystem->dumpFile($filePath, $file->getFileContent());
// @todo how to keep original chmod rights?
// $this->filesystem->chmod($filePath, $smartFileInfo->getPerms());
$errorMessage = \sprintf('System error: "%s"', $throwable->getMessage()) . \PHP_EOL;
$filePath = $filePath instanceof File ? $filePath->getFilePath() : $filePath;
if ($this->rectorOutputStyle->isDebug()) {
return new SystemError($errorMessage . \PHP_EOL . 'Stack trace:' . \PHP_EOL . $throwable->getTraceAsString(), $filePath, $throwable->getLine());
}
$errorMessage .= 'Run Rector with "--debug" option and post the report here: https://github.com/rectorphp/rector/issues/new';
return new SystemError($errorMessage, $filePath, $throwable->getLine());
}
private function invalidateFile(?File $file) : void
{
if (!$file instanceof File) {
return;
}
$this->changedFilesDetector->invalidateFile($file->getFilePath());
}
/**
* Inspired by @see https://github.com/phpstan/phpstan-src/blob/89af4e7db257750cdee5d4259ad312941b6b25e8/src/Analyser/Analyser.php#L134
@ -219,9 +227,6 @@ final class ApplicationFileProcessor
*/
private function runParallel(array $filePaths, Configuration $configuration, InputInterface $input) : array
{
// @todo possibly relative paths?
// must be a string, otherwise the serialization returns empty arrays
// $filePaths // = $this->filePathNormalizer->resolveFilePathsFromFileInfos($filePaths);
$schedule = $this->scheduleFactory->create($this->cpuCoreCountProvider->provide(), SimpleParameterProvider::provideIntParameter(Option::PARALLEL_JOB_SIZE), SimpleParameterProvider::provideIntParameter(Option::PARALLEL_MAX_NUMBER_OF_PROCESSES), $filePaths);
$postFileCallback = static function (int $stepCount) : void {
};

View File

@ -1,32 +0,0 @@
<?php
declare (strict_types=1);
namespace Rector\Core\Application\FileDecorator;
use Rector\ChangesReporting\ValueObjectFactory\FileDiffFactory;
use Rector\Core\ValueObject\Application\File;
final class FileDiffFileDecorator
{
/**
* @readonly
* @var \Rector\ChangesReporting\ValueObjectFactory\FileDiffFactory
*/
private $fileDiffFactory;
public function __construct(FileDiffFactory $fileDiffFactory)
{
$this->fileDiffFactory = $fileDiffFactory;
}
/**
* @param File[] $files
*/
public function decorate(array $files) : void
{
foreach ($files as $file) {
if (!$file->hasChanged()) {
continue;
}
$fileDiff = $this->fileDiffFactory->createFileDiff($file, $file->getOriginalFileContent(), $file->getFileContent());
$file->setFileDiff($fileDiff);
}
}
}

View File

@ -14,7 +14,6 @@ use Rector\Core\Contract\Processor\FileProcessorInterface;
use Rector\Core\Exception\ShouldNotHappenException;
use Rector\Core\FileSystem\FilePathHelper;
use Rector\Core\PhpParser\Printer\FormatPerservingPrinter;
use Rector\Core\Provider\CurrentFileProvider;
use Rector\Core\ValueObject\Application\File;
use Rector\Core\ValueObject\Configuration;
use Rector\Core\ValueObject\Error\SystemError;
@ -51,11 +50,6 @@ final class PhpFileProcessor implements FileProcessorInterface
* @var \Rector\Caching\Detector\ChangedFilesDetector
*/
private $changedFilesDetector;
/**
* @readonly
* @var \Rector\Core\Provider\CurrentFileProvider
*/
private $currentFileProvider;
/**
* @readonly
* @var \Rector\PostRector\Application\PostFileProcessor
@ -81,14 +75,13 @@ final class PhpFileProcessor implements FileProcessorInterface
* @see https://regex101.com/r/xP2MGa/1
*/
private const OPEN_TAG_SPACED_REGEX = '#^(?<open_tag_spaced>[^\\S\\r\\n]+\\<\\?php)#m';
public function __construct(FormatPerservingPrinter $formatPerservingPrinter, FileProcessor $fileProcessor, OutputStyleInterface $rectorOutputStyle, FileDiffFactory $fileDiffFactory, ChangedFilesDetector $changedFilesDetector, CurrentFileProvider $currentFileProvider, PostFileProcessor $postFileProcessor, ErrorFactory $errorFactory, FilePathHelper $filePathHelper, SymfonyStyle $symfonyStyle)
public function __construct(FormatPerservingPrinter $formatPerservingPrinter, FileProcessor $fileProcessor, OutputStyleInterface $rectorOutputStyle, FileDiffFactory $fileDiffFactory, ChangedFilesDetector $changedFilesDetector, PostFileProcessor $postFileProcessor, ErrorFactory $errorFactory, FilePathHelper $filePathHelper, SymfonyStyle $symfonyStyle)
{
$this->formatPerservingPrinter = $formatPerservingPrinter;
$this->fileProcessor = $fileProcessor;
$this->rectorOutputStyle = $rectorOutputStyle;
$this->fileDiffFactory = $fileDiffFactory;
$this->changedFilesDetector = $changedFilesDetector;
$this->currentFileProvider = $currentFileProvider;
$this->postFileProcessor = $postFileProcessor;
$this->errorFactory = $errorFactory;
$this->filePathHelper = $filePathHelper;
@ -163,7 +156,6 @@ final class PhpFileProcessor implements FileProcessorInterface
*/
private function parseFileAndDecorateNodes(File $file) : array
{
$this->currentFileProvider->setFile($file);
$this->notifyFile($file);
try {
$this->fileProcessor->parseFileInfoToLocalCache($file);

View File

@ -19,12 +19,12 @@ final class VersionResolver
* @api
* @var string
*/
public const PACKAGE_VERSION = '6e12886d2444da1471112c2d155fdaaa09ce3d41';
public const PACKAGE_VERSION = '972d7607f1c4ab8b733b91d7aa5020ce1b143538';
/**
* @api
* @var string
*/
public const RELEASE_DATE = '2023-07-19 11:39:25';
public const RELEASE_DATE = '2023-07-19 11:49:53';
/**
* @var int
*/

View File

@ -3,11 +3,9 @@
declare (strict_types=1);
namespace Rector\Core\ValueObjectFactory\Application;
use RectorPrefix202307\Nette\Utils\FileSystem;
use Rector\Caching\Detector\ChangedFilesDetector;
use Rector\Core\Contract\Processor\FileProcessorInterface;
use Rector\Core\FileSystem\FilesFinder;
use Rector\Core\ValueObject\Application\File;
use Rector\Core\ValueObject\Configuration;
/**
* @see \Rector\Core\ValueObject\Application\File
@ -56,18 +54,6 @@ final class FileFactory
};
return \array_filter($filePaths, $fileWithExtensionsFilter);
}
/**
* @param string[] $filePaths
* @return File[]
*/
public function createFromPaths(array $filePaths) : array
{
$files = [];
foreach ($filePaths as $filePath) {
$files[] = new File($filePath, FileSystem::read($filePath));
}
return $files;
}
/**
* @return string[]
*/

2
vendor/autoload.php vendored
View File

@ -22,4 +22,4 @@ if (PHP_VERSION_ID < 50600) {
require_once __DIR__ . '/composer/autoload_real.php';
return ComposerAutoloaderInit430a74aac47c239d6b6776970e1e548c::getLoader();
return ComposerAutoloaderIniteca17cb0d0de8025a8c123919c87bb6e::getLoader();

View File

@ -1495,7 +1495,6 @@ return array(
'Rector\\Config\\RectorConfig' => $baseDir . '/packages/Config/RectorConfig.php',
'Rector\\Core\\Application\\ApplicationFileProcessor' => $baseDir . '/src/Application/ApplicationFileProcessor.php',
'Rector\\Core\\Application\\ChangedNodeScopeRefresher' => $baseDir . '/src/Application/ChangedNodeScopeRefresher.php',
'Rector\\Core\\Application\\FileDecorator\\FileDiffFileDecorator' => $baseDir . '/src/Application/FileDecorator/FileDiffFileDecorator.php',
'Rector\\Core\\Application\\FileProcessor' => $baseDir . '/src/Application/FileProcessor.php',
'Rector\\Core\\Application\\FileProcessor\\PhpFileProcessor' => $baseDir . '/src/Application/FileProcessor/PhpFileProcessor.php',
'Rector\\Core\\Application\\VersionResolver' => $baseDir . '/src/Application/VersionResolver.php',

View File

@ -2,7 +2,7 @@
// autoload_real.php @generated by Composer
class ComposerAutoloaderInit430a74aac47c239d6b6776970e1e548c
class ComposerAutoloaderIniteca17cb0d0de8025a8c123919c87bb6e
{
private static $loader;
@ -22,17 +22,17 @@ class ComposerAutoloaderInit430a74aac47c239d6b6776970e1e548c
return self::$loader;
}
spl_autoload_register(array('ComposerAutoloaderInit430a74aac47c239d6b6776970e1e548c', 'loadClassLoader'), true, true);
spl_autoload_register(array('ComposerAutoloaderIniteca17cb0d0de8025a8c123919c87bb6e', 'loadClassLoader'), true, true);
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__));
spl_autoload_unregister(array('ComposerAutoloaderInit430a74aac47c239d6b6776970e1e548c', 'loadClassLoader'));
spl_autoload_unregister(array('ComposerAutoloaderIniteca17cb0d0de8025a8c123919c87bb6e', 'loadClassLoader'));
require __DIR__ . '/autoload_static.php';
call_user_func(\Composer\Autoload\ComposerStaticInit430a74aac47c239d6b6776970e1e548c::getInitializer($loader));
call_user_func(\Composer\Autoload\ComposerStaticIniteca17cb0d0de8025a8c123919c87bb6e::getInitializer($loader));
$loader->setClassMapAuthoritative(true);
$loader->register(true);
$filesToLoad = \Composer\Autoload\ComposerStaticInit430a74aac47c239d6b6776970e1e548c::$files;
$filesToLoad = \Composer\Autoload\ComposerStaticIniteca17cb0d0de8025a8c123919c87bb6e::$files;
$requireFile = \Closure::bind(static function ($fileIdentifier, $file) {
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
$GLOBALS['__composer_autoload_files'][$fileIdentifier] = true;

View File

@ -4,7 +4,7 @@
namespace Composer\Autoload;
class ComposerStaticInit430a74aac47c239d6b6776970e1e548c
class ComposerStaticIniteca17cb0d0de8025a8c123919c87bb6e
{
public static $files = array (
'ad155f8f1cf0d418fe49e248db8c661b' => __DIR__ . '/..' . '/react/promise/src/functions_include.php',
@ -1749,7 +1749,6 @@ class ComposerStaticInit430a74aac47c239d6b6776970e1e548c
'Rector\\Config\\RectorConfig' => __DIR__ . '/../..' . '/packages/Config/RectorConfig.php',
'Rector\\Core\\Application\\ApplicationFileProcessor' => __DIR__ . '/../..' . '/src/Application/ApplicationFileProcessor.php',
'Rector\\Core\\Application\\ChangedNodeScopeRefresher' => __DIR__ . '/../..' . '/src/Application/ChangedNodeScopeRefresher.php',
'Rector\\Core\\Application\\FileDecorator\\FileDiffFileDecorator' => __DIR__ . '/../..' . '/src/Application/FileDecorator/FileDiffFileDecorator.php',
'Rector\\Core\\Application\\FileProcessor' => __DIR__ . '/../..' . '/src/Application/FileProcessor.php',
'Rector\\Core\\Application\\FileProcessor\\PhpFileProcessor' => __DIR__ . '/../..' . '/src/Application/FileProcessor/PhpFileProcessor.php',
'Rector\\Core\\Application\\VersionResolver' => __DIR__ . '/../..' . '/src/Application/VersionResolver.php',
@ -3027,9 +3026,9 @@ class ComposerStaticInit430a74aac47c239d6b6776970e1e548c
public static function getInitializer(ClassLoader $loader)
{
return \Closure::bind(function () use ($loader) {
$loader->prefixLengthsPsr4 = ComposerStaticInit430a74aac47c239d6b6776970e1e548c::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInit430a74aac47c239d6b6776970e1e548c::$prefixDirsPsr4;
$loader->classMap = ComposerStaticInit430a74aac47c239d6b6776970e1e548c::$classMap;
$loader->prefixLengthsPsr4 = ComposerStaticIniteca17cb0d0de8025a8c123919c87bb6e::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticIniteca17cb0d0de8025a8c123919c87bb6e::$prefixDirsPsr4;
$loader->classMap = ComposerStaticIniteca17cb0d0de8025a8c123919c87bb6e::$classMap;
}, null, ClassLoader::class);
}

View File

@ -1985,12 +1985,12 @@
"source": {
"type": "git",
"url": "https:\/\/github.com\/rectorphp\/rector-downgrade-php.git",
"reference": "734960f3d1ce23f235a3bd1b206551845dbf7aeb"
"reference": "e10ce1addb5f523aa30749cd8dcf77796d46fd09"
},
"dist": {
"type": "zip",
"url": "https:\/\/api.github.com\/repos\/rectorphp\/rector-downgrade-php\/zipball\/734960f3d1ce23f235a3bd1b206551845dbf7aeb",
"reference": "734960f3d1ce23f235a3bd1b206551845dbf7aeb",
"url": "https:\/\/api.github.com\/repos\/rectorphp\/rector-downgrade-php\/zipball\/e10ce1addb5f523aa30749cd8dcf77796d46fd09",
"reference": "e10ce1addb5f523aa30749cd8dcf77796d46fd09",
"shasum": ""
},
"require": {
@ -2014,7 +2014,7 @@
"tomasvotruba\/type-coverage": "^0.2",
"tomasvotruba\/unused-public": "^0.1"
},
"time": "2023-07-12T21:59:50+00:00",
"time": "2023-07-19T10:46:18+00:00",
"default-branch": true,
"type": "rector-extension",
"extra": {

File diff suppressed because one or more lines are too long

View File

@ -9,7 +9,7 @@ namespace Rector\RectorInstaller;
*/
final class GeneratedConfig
{
public const EXTENSIONS = array('rector/rector-doctrine' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-doctrine', 'relative_install_path' => '../../rector-doctrine', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main 2d14418'), 'rector/rector-downgrade-php' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-downgrade-php', 'relative_install_path' => '../../rector-downgrade-php', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main 734960f'), 'rector/rector-phpunit' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-phpunit', 'relative_install_path' => '../../rector-phpunit', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main 3918e6f'), 'rector/rector-symfony' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-symfony', 'relative_install_path' => '../../rector-symfony', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main a0af12a'));
public const EXTENSIONS = array('rector/rector-doctrine' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-doctrine', 'relative_install_path' => '../../rector-doctrine', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main 2d14418'), 'rector/rector-downgrade-php' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-downgrade-php', 'relative_install_path' => '../../rector-downgrade-php', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main e10ce1a'), 'rector/rector-phpunit' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-phpunit', 'relative_install_path' => '../../rector-phpunit', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main 3918e6f'), 'rector/rector-symfony' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-symfony', 'relative_install_path' => '../../rector-symfony', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main a0af12a'));
private function __construct()
{
}

View File

@ -8,7 +8,6 @@ use PhpParser\Node\Param;
use PhpParser\Node\Stmt\ClassLike;
use PhpParser\Node\Stmt\ClassMethod;
use PHPStan\Reflection\ClassReflection;
use Rector\Core\Contract\Rector\AllowEmptyConfigurableRectorInterface;
use Rector\Core\Rector\AbstractRector;
use Rector\Core\Reflection\ReflectionResolver;
use Rector\DowngradePhp72\NodeAnalyzer\BuiltInMethodAnalyzer;
@ -25,7 +24,7 @@ use RectorPrefix202307\Webmozart\Assert\Assert;
*
* @see \Rector\Tests\DowngradePhp72\Rector\ClassMethod\DowngradeParameterTypeWideningRector\DowngradeParameterTypeWideningRectorTest
*/
final class DowngradeParameterTypeWideningRector extends AbstractRector implements AllowEmptyConfigurableRectorInterface
final class DowngradeParameterTypeWideningRector extends AbstractRector
{
/**
* @readonly