Updated Rector to commit e2a663644661e2726413a88f228784d6879f5e4e

e2a6636446 [DX] Make use of Laravel container - step #12 (#4707)
This commit is contained in:
Tomas Votruba 2023-08-07 17:39:41 +00:00
parent ce76f6974a
commit 7e2a628d19
8 changed files with 34 additions and 19 deletions

View File

@ -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
*/

View File

@ -34,14 +34,18 @@ final class ConfigInitializer
*/
private $rectors = [];
/**
* @param RewindableGenerator<RectorInterface> $rectors
* @param RewindableGenerator<RectorInterface>|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
{

View File

@ -35,7 +35,7 @@ final class ListRulesCommand extends Command
/**
* @param RewindableGenerator<RectorInterface> $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;

View File

@ -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);

View File

@ -24,12 +24,12 @@ final class RectorNodeTraverser extends NodeTraverser
*/
private $phpRectors = [];
/**
* @param RewindableGenerator<PhpRectorInterface> $phpRectors
* @param RewindableGenerator<PhpRectorInterface>|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();
}
/**

2
vendor/autoload.php vendored
View File

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

View File

@ -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;

View File

@ -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);
}