diff --git a/src/Application/VersionResolver.php b/src/Application/VersionResolver.php index 50886401a3b..f6eb5445809 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 = 'efdbf98138d1bdd2e864c9e4abcfc53f7b88b3f0'; + public const PACKAGE_VERSION = 'e2a663644661e2726413a88f228784d6879f5e4e'; /** * @api * @var string */ - public const RELEASE_DATE = '2023-08-07 16:26:53'; + public const RELEASE_DATE = '2023-08-07 17:36:13'; /** * @var int */ diff --git a/src/Configuration/ConfigInitializer.php b/src/Configuration/ConfigInitializer.php index 9da23a068ca..84a7914a4f6 100644 --- a/src/Configuration/ConfigInitializer.php +++ b/src/Configuration/ConfigInitializer.php @@ -34,14 +34,18 @@ final class ConfigInitializer */ private $rectors = []; /** - * @param RewindableGenerator $rectors + * @param RewindableGenerator|RectorInterface[] $rectors */ - public function __construct(RewindableGenerator $rectors, InitFilePathsResolver $initFilePathsResolver, SymfonyStyle $symfonyStyle, PhpVersionProvider $phpVersionProvider) + public function __construct(iterable $rectors, InitFilePathsResolver $initFilePathsResolver, SymfonyStyle $symfonyStyle, PhpVersionProvider $phpVersionProvider) { $this->initFilePathsResolver = $initFilePathsResolver; $this->symfonyStyle = $symfonyStyle; $this->phpVersionProvider = $phpVersionProvider; - $this->rectors = \iterator_to_array($rectors); + if ($rectors instanceof RewindableGenerator) { + $this->rectors = \iterator_to_array($rectors->getIterator()); + } else { + $this->rectors = $rectors; + } } public function createConfig(string $projectDirectory) : void { diff --git a/src/Console/Command/ListRulesCommand.php b/src/Console/Command/ListRulesCommand.php index f0c05256a48..83d76081da1 100644 --- a/src/Console/Command/ListRulesCommand.php +++ b/src/Console/Command/ListRulesCommand.php @@ -35,7 +35,7 @@ final class ListRulesCommand extends Command /** * @param RewindableGenerator $rectors */ - public function __construct(RectorOutputStyle $rectorOutputStyle, SkippedClassResolver $skippedClassResolver, RewindableGenerator $rectors) + public function __construct(RectorOutputStyle $rectorOutputStyle, SkippedClassResolver $skippedClassResolver, iterable $rectors) { $this->rectorOutputStyle = $rectorOutputStyle; $this->skippedClassResolver = $skippedClassResolver; diff --git a/src/DependencyInjection/LazyContainerFactory.php b/src/DependencyInjection/LazyContainerFactory.php index 55ee99c14be..aee546d289e 100644 --- a/src/DependencyInjection/LazyContainerFactory.php +++ b/src/DependencyInjection/LazyContainerFactory.php @@ -39,14 +39,18 @@ use Rector\Config\LazyRectorConfig; use Rector\Core\Application\ApplicationFileProcessor; use Rector\Core\Application\ChangedNodeScopeRefresher; use Rector\Core\Application\FileProcessor\PhpFileProcessor; +use Rector\Core\Configuration\ConfigInitializer; use Rector\Core\Configuration\CurrentNodeProvider; +use Rector\Core\Console\Output\OutputFormatterCollector; use Rector\Core\Console\Output\RectorOutputStyle; use Rector\Core\Console\Style\RectorConsoleOutputStyle; use Rector\Core\Console\Style\RectorConsoleOutputStyleFactory; +use Rector\Core\Console\Style\SymfonyStyleFactory; use Rector\Core\Contract\Console\OutputStyleInterface; use Rector\Core\Contract\Processor\FileProcessorInterface; use Rector\Core\Contract\Rector\NonPhpRectorInterface; use Rector\Core\Contract\Rector\PhpRectorInterface; +use Rector\Core\Contract\Rector\RectorInterface; use Rector\Core\FileSystem\FilePathHelper; use Rector\Core\Logging\CurrentRectorProvider; use Rector\Core\NodeDecorator\CreatedByRuleDecorator; @@ -169,6 +173,7 @@ use Rector\StaticTypeMapper\PhpParser\StringNodeMapper; use Rector\StaticTypeMapper\PhpParser\UnionTypeNodeMapper; use Rector\StaticTypeMapper\StaticTypeMapper; use RectorPrefix202308\Symfony\Component\Console\Application; +use RectorPrefix202308\Symfony\Component\Console\Style\SymfonyStyle; use RectorPrefix202308\Webmozart\Assert\Assert; final class LazyContainerFactory { @@ -258,6 +263,7 @@ final class LazyContainerFactory $lazyRectorConfig->when(ApplicationFileProcessor::class)->needs('$fileProcessors')->giveTagged(FileProcessorInterface::class); $lazyRectorConfig->when(FileFactory::class)->needs('$fileProcessors')->giveTagged(FileProcessorInterface::class); $lazyRectorConfig->when(RectorNodeTraverser::class)->needs('$phpRectors')->giveTagged(PhpRectorInterface::class); + $lazyRectorConfig->when(ConfigInitializer::class)->needs('$rectors')->giveTagged(RectorInterface::class); $lazyRectorConfig->singleton(RectorConsoleOutputStyle::class, static function (Container $container) : RectorConsoleOutputStyle { $rectorConsoleOutputStyleFactory = $container->make(RectorConsoleOutputStyleFactory::class); return $rectorConsoleOutputStyleFactory->create(); @@ -292,8 +298,13 @@ final class LazyContainerFactory $this->registerTagged($lazyRectorConfig, self::NODE_TYPE_RESOLVER_CLASSES, NodeTypeResolverInterface::class); $this->registerTagged($lazyRectorConfig, self::OUTPUT_FORMATTER_CLASSES, OutputFormatterInterface::class); $this->registerTagged($lazyRectorConfig, self::CLASS_NAME_IMPORT_SKIPPER_CLASSES, ClassNameImportSkipVoterInterface::class); + $lazyRectorConfig->singleton(SymfonyStyle::class, static function (Container $container) : SymfonyStyle { + $symfonyStyleFactory = $container->make(SymfonyStyleFactory::class); + return $symfonyStyleFactory->create(); + }); $this->registerTagged($lazyRectorConfig, self::ANNOTATION_TO_ATTRIBUTE_MAPPER_CLASSES, AnnotationToAttributeMapperInterface::class); $lazyRectorConfig->when(AnnotationToAttributeMapper::class)->needs('$annotationToAttributeMappers')->giveTagged(AnnotationToAttributeMapperInterface::class); + $lazyRectorConfig->when(OutputFormatterCollector::class)->needs('$outputFormatters')->giveTagged(OutputFormatterInterface::class); // #[Required]-like setter $lazyRectorConfig->afterResolving(ArrayAnnotationToAttributeMapper::class, static function (ArrayAnnotationToAttributeMapper $arrayAnnotationToAttributeMapper, Container $container) : void { $annotationToAttributesMapper = $container->make(AnnotationToAttributeMapper::class); diff --git a/src/PhpParser/NodeTraverser/RectorNodeTraverser.php b/src/PhpParser/NodeTraverser/RectorNodeTraverser.php index 65ba902caea..b3cd4c4556d 100644 --- a/src/PhpParser/NodeTraverser/RectorNodeTraverser.php +++ b/src/PhpParser/NodeTraverser/RectorNodeTraverser.php @@ -24,12 +24,12 @@ final class RectorNodeTraverser extends NodeTraverser */ private $phpRectors = []; /** - * @param RewindableGenerator $phpRectors + * @param RewindableGenerator|PhpRectorInterface[] $phpRectors */ - public function __construct(RewindableGenerator $phpRectors, PhpVersionedFilter $phpVersionedFilter) + public function __construct(iterable $phpRectors, PhpVersionedFilter $phpVersionedFilter) { $this->phpVersionedFilter = $phpVersionedFilter; - $this->phpRectors = \iterator_to_array($phpRectors); + $this->phpRectors = \is_array($phpRectors) ? $phpRectors : \iterator_to_array($phpRectors); parent::__construct(); } /** diff --git a/vendor/autoload.php b/vendor/autoload.php index e9133bc50c8..25c4ee4dac9 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 ComposerAutoloaderInit520c534ffd8dd5ac9be2d706dfdf98bc::getLoader(); +return ComposerAutoloaderInitbc83e9a3704d02eea9424ec3241fe1b8::getLoader(); diff --git a/vendor/composer/autoload_real.php b/vendor/composer/autoload_real.php index f5fd8c97681..d840a95486c 100644 --- a/vendor/composer/autoload_real.php +++ b/vendor/composer/autoload_real.php @@ -2,7 +2,7 @@ // autoload_real.php @generated by Composer -class ComposerAutoloaderInit520c534ffd8dd5ac9be2d706dfdf98bc +class ComposerAutoloaderInitbc83e9a3704d02eea9424ec3241fe1b8 { private static $loader; @@ -22,17 +22,17 @@ class ComposerAutoloaderInit520c534ffd8dd5ac9be2d706dfdf98bc return self::$loader; } - spl_autoload_register(array('ComposerAutoloaderInit520c534ffd8dd5ac9be2d706dfdf98bc', 'loadClassLoader'), true, true); + spl_autoload_register(array('ComposerAutoloaderInitbc83e9a3704d02eea9424ec3241fe1b8', 'loadClassLoader'), true, true); self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__)); - spl_autoload_unregister(array('ComposerAutoloaderInit520c534ffd8dd5ac9be2d706dfdf98bc', 'loadClassLoader')); + spl_autoload_unregister(array('ComposerAutoloaderInitbc83e9a3704d02eea9424ec3241fe1b8', 'loadClassLoader')); require __DIR__ . '/autoload_static.php'; - call_user_func(\Composer\Autoload\ComposerStaticInit520c534ffd8dd5ac9be2d706dfdf98bc::getInitializer($loader)); + call_user_func(\Composer\Autoload\ComposerStaticInitbc83e9a3704d02eea9424ec3241fe1b8::getInitializer($loader)); $loader->setClassMapAuthoritative(true); $loader->register(true); - $filesToLoad = \Composer\Autoload\ComposerStaticInit520c534ffd8dd5ac9be2d706dfdf98bc::$files; + $filesToLoad = \Composer\Autoload\ComposerStaticInitbc83e9a3704d02eea9424ec3241fe1b8::$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 e0167d2ca85..b17f6631952 100644 --- a/vendor/composer/autoload_static.php +++ b/vendor/composer/autoload_static.php @@ -4,7 +4,7 @@ namespace Composer\Autoload; -class ComposerStaticInit520c534ffd8dd5ac9be2d706dfdf98bc +class ComposerStaticInitbc83e9a3704d02eea9424ec3241fe1b8 { public static $files = array ( 'ad155f8f1cf0d418fe49e248db8c661b' => __DIR__ . '/..' . '/react/promise/src/functions_include.php', @@ -3012,9 +3012,9 @@ class ComposerStaticInit520c534ffd8dd5ac9be2d706dfdf98bc public static function getInitializer(ClassLoader $loader) { return \Closure::bind(function () use ($loader) { - $loader->prefixLengthsPsr4 = ComposerStaticInit520c534ffd8dd5ac9be2d706dfdf98bc::$prefixLengthsPsr4; - $loader->prefixDirsPsr4 = ComposerStaticInit520c534ffd8dd5ac9be2d706dfdf98bc::$prefixDirsPsr4; - $loader->classMap = ComposerStaticInit520c534ffd8dd5ac9be2d706dfdf98bc::$classMap; + $loader->prefixLengthsPsr4 = ComposerStaticInitbc83e9a3704d02eea9424ec3241fe1b8::$prefixLengthsPsr4; + $loader->prefixDirsPsr4 = ComposerStaticInitbc83e9a3704d02eea9424ec3241fe1b8::$prefixDirsPsr4; + $loader->classMap = ComposerStaticInitbc83e9a3704d02eea9424ec3241fe1b8::$classMap; }, null, ClassLoader::class); }