mirror of
https://github.com/rectorphp/rector.git
synced 2025-04-11 11:02:38 +02:00
Rector 0.18.0
This commit is contained in:
parent
b8fef75121
commit
758ada29b5
@ -5,6 +5,7 @@ namespace Rector\Core\Application;
|
||||
|
||||
use RectorPrefix202308\Nette\Utils\FileSystem as UtilsFileSystem;
|
||||
use Rector\Caching\Detector\ChangedFilesDetector;
|
||||
use Rector\Core\Application\FileProcessor\PhpFileProcessor;
|
||||
use Rector\Core\Configuration\Option;
|
||||
use Rector\Core\Configuration\Parameter\SimpleParameterProvider;
|
||||
use Rector\Core\Contract\Processor\FileProcessorInterface;
|
||||
@ -67,6 +68,11 @@ final class ApplicationFileProcessor
|
||||
* @var \Rector\Core\Provider\CurrentFileProvider
|
||||
*/
|
||||
private $currentFileProvider;
|
||||
/**
|
||||
* @readonly
|
||||
* @var \Rector\Core\Application\FileProcessor\PhpFileProcessor
|
||||
*/
|
||||
private $phpFileProcessor;
|
||||
/**
|
||||
* @var FileProcessorInterface[]
|
||||
* @readonly
|
||||
@ -83,7 +89,7 @@ final class ApplicationFileProcessor
|
||||
/**
|
||||
* @param FileProcessorInterface[] $fileProcessors
|
||||
*/
|
||||
public function __construct(SymfonyStyle $symfonyStyle, FileFactory $fileFactory, ArrayParametersMerger $arrayParametersMerger, ParallelFileProcessor $parallelFileProcessor, ScheduleFactory $scheduleFactory, CpuCoreCountProvider $cpuCoreCountProvider, ChangedFilesDetector $changedFilesDetector, CurrentFileProvider $currentFileProvider, array $fileProcessors)
|
||||
public function __construct(SymfonyStyle $symfonyStyle, FileFactory $fileFactory, ArrayParametersMerger $arrayParametersMerger, ParallelFileProcessor $parallelFileProcessor, ScheduleFactory $scheduleFactory, CpuCoreCountProvider $cpuCoreCountProvider, ChangedFilesDetector $changedFilesDetector, CurrentFileProvider $currentFileProvider, PhpFileProcessor $phpFileProcessor, array $fileProcessors)
|
||||
{
|
||||
$this->symfonyStyle = $symfonyStyle;
|
||||
$this->fileFactory = $fileFactory;
|
||||
@ -93,12 +99,17 @@ final class ApplicationFileProcessor
|
||||
$this->cpuCoreCountProvider = $cpuCoreCountProvider;
|
||||
$this->changedFilesDetector = $changedFilesDetector;
|
||||
$this->currentFileProvider = $currentFileProvider;
|
||||
$this->phpFileProcessor = $phpFileProcessor;
|
||||
$this->fileProcessors = $fileProcessors;
|
||||
$fileProcessorClasses = [];
|
||||
foreach ($this->fileProcessors as $fileProcessor) {
|
||||
\trigger_error(\sprintf('Rector will support only PHP, as that is the only code the AST can handle.%sThe custom "%s" file processor will not be supported, and should be refactored into own tool with file finder/printer.', \PHP_EOL, \get_class($fileProcessor)) . \PHP_EOL . \PHP_EOL, \E_USER_WARNING);
|
||||
// to notice
|
||||
\sleep(2);
|
||||
}
|
||||
foreach ($fileProcessors as $fileProcessor) {
|
||||
$fileProcessorClasses[] = \get_class($fileProcessor);
|
||||
}
|
||||
Assert::notEmpty($fileProcessorClasses);
|
||||
Assert::uniqueValues($fileProcessorClasses);
|
||||
}
|
||||
/**
|
||||
@ -161,13 +172,11 @@ final class ApplicationFileProcessor
|
||||
private function processFile(File $file, array $systemErrorsAndFileDiffs, Configuration $configuration) : array
|
||||
{
|
||||
$this->currentFileProvider->setFile($file);
|
||||
foreach ($this->fileProcessors as $fileProcessor) {
|
||||
if (!$fileProcessor->supports($file, $configuration)) {
|
||||
continue;
|
||||
}
|
||||
$result = $fileProcessor->process($file, $configuration);
|
||||
$systemErrorsAndFileDiffs = $this->arrayParametersMerger->merge($systemErrorsAndFileDiffs, $result);
|
||||
}
|
||||
// BC layer, soon the file processors will be removed
|
||||
$otherSystemErrorsAndFileDiffs = $this->processWithFileProcessors($file, $configuration, $systemErrorsAndFileDiffs);
|
||||
$systemErrorsAndFileDiffs = $this->arrayParametersMerger->merge($systemErrorsAndFileDiffs, $otherSystemErrorsAndFileDiffs);
|
||||
$phpSystemErrorsAndFileDiffs = $this->phpFileProcessor->process($file, $configuration);
|
||||
$systemErrorsAndFileDiffs = $this->arrayParametersMerger->merge($systemErrorsAndFileDiffs, $phpSystemErrorsAndFileDiffs);
|
||||
if ($systemErrorsAndFileDiffs[Bridge::SYSTEM_ERRORS] !== []) {
|
||||
$this->changedFilesDetector->invalidateFile($file->getFilePath());
|
||||
} elseif (!$configuration->isDryRun() || $systemErrorsAndFileDiffs[Bridge::FILE_DIFFS] === []) {
|
||||
@ -251,4 +260,21 @@ final class ApplicationFileProcessor
|
||||
}
|
||||
return $potentialEcsBinaryPath;
|
||||
}
|
||||
/**
|
||||
* @deprecated Custom file processors are deprecated. Use custom tool instead.
|
||||
*
|
||||
* @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 processWithFileProcessors(File $file, Configuration $configuration, array $systemErrorsAndFileDiffs)
|
||||
{
|
||||
foreach ($this->fileProcessors as $fileProcessor) {
|
||||
if (!$fileProcessor->supports($file, $configuration)) {
|
||||
continue;
|
||||
}
|
||||
$result = $fileProcessor->process($file, $configuration);
|
||||
$systemErrorsAndFileDiffs = $this->arrayParametersMerger->merge($systemErrorsAndFileDiffs, $result);
|
||||
}
|
||||
return $systemErrorsAndFileDiffs;
|
||||
}
|
||||
}
|
||||
|
@ -9,7 +9,6 @@ use Rector\Caching\Detector\ChangedFilesDetector;
|
||||
use Rector\ChangesReporting\ValueObjectFactory\ErrorFactory;
|
||||
use Rector\ChangesReporting\ValueObjectFactory\FileDiffFactory;
|
||||
use Rector\Core\Application\FileProcessor;
|
||||
use Rector\Core\Contract\Processor\FileProcessorInterface;
|
||||
use Rector\Core\Exception\ShouldNotHappenException;
|
||||
use Rector\Core\FileSystem\FilePathHelper;
|
||||
use Rector\Core\PhpParser\Printer\FormatPerservingPrinter;
|
||||
@ -22,7 +21,7 @@ use Rector\PostRector\Application\PostFileProcessor;
|
||||
use Rector\Testing\PHPUnit\StaticPHPUnitEnvironment;
|
||||
use RectorPrefix202308\Symfony\Component\Console\Style\SymfonyStyle;
|
||||
use Throwable;
|
||||
final class PhpFileProcessor implements FileProcessorInterface
|
||||
final class PhpFileProcessor
|
||||
{
|
||||
/**
|
||||
* @readonly
|
||||
@ -128,17 +127,6 @@ final class PhpFileProcessor implements FileProcessorInterface
|
||||
$systemErrorsAndFileDiffs[Bridge::FILE_DIFFS] = [$fileDiff];
|
||||
return $systemErrorsAndFileDiffs;
|
||||
}
|
||||
public function supports(File $file, Configuration $configuration) : bool
|
||||
{
|
||||
return \true;
|
||||
}
|
||||
/**
|
||||
* @return string[]
|
||||
*/
|
||||
public function getSupportedFileExtensions() : array
|
||||
{
|
||||
return ['php'];
|
||||
}
|
||||
/**
|
||||
* @return SystemError[]
|
||||
*/
|
||||
|
@ -19,12 +19,12 @@ final class VersionResolver
|
||||
* @api
|
||||
* @var string
|
||||
*/
|
||||
public const PACKAGE_VERSION = 'dc580ae1bb540eed78d915db46168b39c1469b42';
|
||||
public const PACKAGE_VERSION = '0.18.0';
|
||||
/**
|
||||
* @api
|
||||
* @var string
|
||||
*/
|
||||
public const RELEASE_DATE = '2023-08-17 13:11:59';
|
||||
public const RELEASE_DATE = '2023-08-17 14:49:44';
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
|
@ -9,6 +9,8 @@ use Rector\Core\ValueObject\Error\SystemError;
|
||||
use Rector\Core\ValueObject\Reporting\FileDiff;
|
||||
/**
|
||||
* @internal
|
||||
*
|
||||
* @deprecated This interface should not be used, as Rector will handle PHP code only. Use custom file processor with own finder instead for any non-PHP changes.
|
||||
*/
|
||||
interface FileProcessorInterface
|
||||
{
|
||||
|
@ -292,7 +292,6 @@ final class LazyContainerFactory
|
||||
}
|
||||
$rectorConfig->alias(TypeParser::class, BetterTypeParser::class);
|
||||
$rectorConfig->singleton(PhpFileProcessor::class);
|
||||
$rectorConfig->tag(PhpFileProcessor::class, FileProcessorInterface::class);
|
||||
$rectorConfig->singleton(PostFileProcessor::class);
|
||||
if (\class_exists(InitRecipeCommand::class)) {
|
||||
$rectorConfig->tag(InitRecipeCommand::class, Command::class);
|
||||
|
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 ComposerAutoloaderInit09bf9b7ae79c8d3442a2002158653e4a::getLoader();
|
||||
return ComposerAutoloaderInitae1b297561b2af333af4101d3842f5ee::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 ComposerAutoloaderInit09bf9b7ae79c8d3442a2002158653e4a
|
||||
class ComposerAutoloaderInitae1b297561b2af333af4101d3842f5ee
|
||||
{
|
||||
private static $loader;
|
||||
|
||||
@ -22,17 +22,17 @@ class ComposerAutoloaderInit09bf9b7ae79c8d3442a2002158653e4a
|
||||
return self::$loader;
|
||||
}
|
||||
|
||||
spl_autoload_register(array('ComposerAutoloaderInit09bf9b7ae79c8d3442a2002158653e4a', 'loadClassLoader'), true, true);
|
||||
spl_autoload_register(array('ComposerAutoloaderInitae1b297561b2af333af4101d3842f5ee', 'loadClassLoader'), true, true);
|
||||
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__));
|
||||
spl_autoload_unregister(array('ComposerAutoloaderInit09bf9b7ae79c8d3442a2002158653e4a', 'loadClassLoader'));
|
||||
spl_autoload_unregister(array('ComposerAutoloaderInitae1b297561b2af333af4101d3842f5ee', 'loadClassLoader'));
|
||||
|
||||
require __DIR__ . '/autoload_static.php';
|
||||
call_user_func(\Composer\Autoload\ComposerStaticInit09bf9b7ae79c8d3442a2002158653e4a::getInitializer($loader));
|
||||
call_user_func(\Composer\Autoload\ComposerStaticInitae1b297561b2af333af4101d3842f5ee::getInitializer($loader));
|
||||
|
||||
$loader->setClassMapAuthoritative(true);
|
||||
$loader->register(true);
|
||||
|
||||
$filesToLoad = \Composer\Autoload\ComposerStaticInit09bf9b7ae79c8d3442a2002158653e4a::$files;
|
||||
$filesToLoad = \Composer\Autoload\ComposerStaticInitae1b297561b2af333af4101d3842f5ee::$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 ComposerStaticInit09bf9b7ae79c8d3442a2002158653e4a
|
||||
class ComposerStaticInitae1b297561b2af333af4101d3842f5ee
|
||||
{
|
||||
public static $files = array (
|
||||
'ad155f8f1cf0d418fe49e248db8c661b' => __DIR__ . '/..' . '/react/promise/src/functions_include.php',
|
||||
@ -2638,9 +2638,9 @@ class ComposerStaticInit09bf9b7ae79c8d3442a2002158653e4a
|
||||
public static function getInitializer(ClassLoader $loader)
|
||||
{
|
||||
return \Closure::bind(function () use ($loader) {
|
||||
$loader->prefixLengthsPsr4 = ComposerStaticInit09bf9b7ae79c8d3442a2002158653e4a::$prefixLengthsPsr4;
|
||||
$loader->prefixDirsPsr4 = ComposerStaticInit09bf9b7ae79c8d3442a2002158653e4a::$prefixDirsPsr4;
|
||||
$loader->classMap = ComposerStaticInit09bf9b7ae79c8d3442a2002158653e4a::$classMap;
|
||||
$loader->prefixLengthsPsr4 = ComposerStaticInitae1b297561b2af333af4101d3842f5ee::$prefixLengthsPsr4;
|
||||
$loader->prefixDirsPsr4 = ComposerStaticInitae1b297561b2af333af4101d3842f5ee::$prefixDirsPsr4;
|
||||
$loader->classMap = ComposerStaticInitae1b297561b2af333af4101d3842f5ee::$classMap;
|
||||
|
||||
}, null, ClassLoader::class);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user