mirror of
https://github.com/rectorphp/rector.git
synced 2025-04-06 00:22:57 +02:00
Updated Rector to commit ce87fc223b14aed6cef72ac79e00f4bee6afbbbb
ce87fc223b
[Config] Add merging of rules configuration, call configure() just once (#4838)
This commit is contained in:
parent
ef0d7bee6c
commit
f3e1fd5fad
@ -21,6 +21,10 @@ use RectorPrefix202308\Webmozart\Assert\Assert;
|
||||
*/
|
||||
final class RectorConfig extends Container
|
||||
{
|
||||
/**
|
||||
* @var array<class-string<RectorInterface>, mixed[]>>
|
||||
*/
|
||||
private $ruleConfigurations = [];
|
||||
/**
|
||||
* @param string[] $paths
|
||||
*/
|
||||
@ -138,11 +142,19 @@ final class RectorConfig extends Container
|
||||
Assert::classExists($rectorClass);
|
||||
Assert::isAOf($rectorClass, RectorInterface::class);
|
||||
Assert::isAOf($rectorClass, ConfigurableRectorInterface::class);
|
||||
// store configuration to cache
|
||||
$this->ruleConfigurations[$rectorClass] = \array_merge($this->ruleConfigurations[$rectorClass] ?? [], $configuration);
|
||||
$isBound = $this->bound($rectorClass);
|
||||
// avoid double registration
|
||||
if ($isBound) {
|
||||
return;
|
||||
}
|
||||
$this->singleton($rectorClass);
|
||||
$this->afterResolving($rectorClass, static function (ConfigurableRectorInterface $configurableRector) use($configuration) : void {
|
||||
$configurableRector->configure($configuration);
|
||||
});
|
||||
$this->tagRectorService($rectorClass);
|
||||
$this->afterResolving($rectorClass, function (ConfigurableRectorInterface $configurableRector) use($rectorClass) : void {
|
||||
$ruleConfiguration = $this->ruleConfigurations[$rectorClass];
|
||||
$configurableRector->configure($ruleConfiguration);
|
||||
});
|
||||
}
|
||||
/**
|
||||
* @param class-string<RectorInterface> $rectorClass
|
||||
@ -161,15 +173,6 @@ final class RectorConfig extends Container
|
||||
});
|
||||
}
|
||||
}
|
||||
private function importFile(string $filePath) : void
|
||||
{
|
||||
Assert::fileExists($filePath);
|
||||
$self = $this;
|
||||
$callable = (require $filePath);
|
||||
Assert::isCallable($callable);
|
||||
/** @var callable(Container $container): void $callable */
|
||||
$callable($self);
|
||||
}
|
||||
public function import(string $filePath) : void
|
||||
{
|
||||
$paths = [$filePath];
|
||||
@ -264,6 +267,15 @@ final class RectorConfig extends Container
|
||||
{
|
||||
\trigger_error('The services() method is deprecated. Use $rectorConfig->singleton(ServiceType::class) instead', \E_USER_ERROR);
|
||||
}
|
||||
private function importFile(string $filePath) : void
|
||||
{
|
||||
Assert::fileExists($filePath);
|
||||
$self = $this;
|
||||
$callable = (require $filePath);
|
||||
Assert::isCallable($callable);
|
||||
/** @var callable(Container $container): void $callable */
|
||||
$callable($self);
|
||||
}
|
||||
/**
|
||||
* @param mixed $skipRule
|
||||
*/
|
||||
@ -308,4 +320,8 @@ final class RectorConfig extends Container
|
||||
}
|
||||
throw new ShouldNotHappenException('Following rules are registered twice: ' . \implode(', ', $duplicatedRectorClasses));
|
||||
}
|
||||
public function resetRuleConfigurations() : void
|
||||
{
|
||||
$this->ruleConfigurations = [];
|
||||
}
|
||||
}
|
||||
|
@ -74,6 +74,7 @@ abstract class AbstractRectorTestCase extends \Rector\Testing\PHPUnit\AbstractLa
|
||||
$resetable->reset();
|
||||
}
|
||||
$this->forgetRectorsRules();
|
||||
$rectorConfig->resetRuleConfigurations();
|
||||
// this has to be always empty, so we can add new rules with their configuration
|
||||
$this->assertEmpty($rectorConfig->tagged(RectorInterface::class));
|
||||
$this->bootFromConfigFiles([$configFile]);
|
||||
@ -88,7 +89,6 @@ abstract class AbstractRectorTestCase extends \Rector\Testing\PHPUnit\AbstractLa
|
||||
$rectorNodeTraverser->refreshPhpRectors($phpRectors);
|
||||
// store cache
|
||||
self::$cacheByRuleAndConfig[$cacheKey] = \true;
|
||||
self::$cacheByRuleAndConfig[$cacheKey] = \true;
|
||||
}
|
||||
$this->applicationFileProcessor = $this->make(ApplicationFileProcessor::class);
|
||||
$this->dynamicSourceLocatorProvider = $this->make(DynamicSourceLocatorProvider::class);
|
||||
|
@ -19,12 +19,12 @@ final class VersionResolver
|
||||
* @api
|
||||
* @var string
|
||||
*/
|
||||
public const PACKAGE_VERSION = '4b34887e678f90e4d9a8b4838333091465c28dc7';
|
||||
public const PACKAGE_VERSION = 'ce87fc223b14aed6cef72ac79e00f4bee6afbbbb';
|
||||
/**
|
||||
* @api
|
||||
* @var string
|
||||
*/
|
||||
public const RELEASE_DATE = '2023-08-23 18:29:26';
|
||||
public const RELEASE_DATE = '2023-08-23 15:17:47';
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
|
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 ComposerAutoloaderInit0c1cbd1b21ce40fab1374c1cd52c00dd::getLoader();
|
||||
return ComposerAutoloaderInit3c4b06edaaaca82bbe48a07d10a1d2cb::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 ComposerAutoloaderInit0c1cbd1b21ce40fab1374c1cd52c00dd
|
||||
class ComposerAutoloaderInit3c4b06edaaaca82bbe48a07d10a1d2cb
|
||||
{
|
||||
private static $loader;
|
||||
|
||||
@ -22,17 +22,17 @@ class ComposerAutoloaderInit0c1cbd1b21ce40fab1374c1cd52c00dd
|
||||
return self::$loader;
|
||||
}
|
||||
|
||||
spl_autoload_register(array('ComposerAutoloaderInit0c1cbd1b21ce40fab1374c1cd52c00dd', 'loadClassLoader'), true, true);
|
||||
spl_autoload_register(array('ComposerAutoloaderInit3c4b06edaaaca82bbe48a07d10a1d2cb', 'loadClassLoader'), true, true);
|
||||
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__));
|
||||
spl_autoload_unregister(array('ComposerAutoloaderInit0c1cbd1b21ce40fab1374c1cd52c00dd', 'loadClassLoader'));
|
||||
spl_autoload_unregister(array('ComposerAutoloaderInit3c4b06edaaaca82bbe48a07d10a1d2cb', 'loadClassLoader'));
|
||||
|
||||
require __DIR__ . '/autoload_static.php';
|
||||
call_user_func(\Composer\Autoload\ComposerStaticInit0c1cbd1b21ce40fab1374c1cd52c00dd::getInitializer($loader));
|
||||
call_user_func(\Composer\Autoload\ComposerStaticInit3c4b06edaaaca82bbe48a07d10a1d2cb::getInitializer($loader));
|
||||
|
||||
$loader->setClassMapAuthoritative(true);
|
||||
$loader->register(true);
|
||||
|
||||
$filesToLoad = \Composer\Autoload\ComposerStaticInit0c1cbd1b21ce40fab1374c1cd52c00dd::$files;
|
||||
$filesToLoad = \Composer\Autoload\ComposerStaticInit3c4b06edaaaca82bbe48a07d10a1d2cb::$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 ComposerStaticInit0c1cbd1b21ce40fab1374c1cd52c00dd
|
||||
class ComposerStaticInit3c4b06edaaaca82bbe48a07d10a1d2cb
|
||||
{
|
||||
public static $files = array (
|
||||
'ad155f8f1cf0d418fe49e248db8c661b' => __DIR__ . '/..' . '/react/promise/src/functions_include.php',
|
||||
@ -2610,9 +2610,9 @@ class ComposerStaticInit0c1cbd1b21ce40fab1374c1cd52c00dd
|
||||
public static function getInitializer(ClassLoader $loader)
|
||||
{
|
||||
return \Closure::bind(function () use ($loader) {
|
||||
$loader->prefixLengthsPsr4 = ComposerStaticInit0c1cbd1b21ce40fab1374c1cd52c00dd::$prefixLengthsPsr4;
|
||||
$loader->prefixDirsPsr4 = ComposerStaticInit0c1cbd1b21ce40fab1374c1cd52c00dd::$prefixDirsPsr4;
|
||||
$loader->classMap = ComposerStaticInit0c1cbd1b21ce40fab1374c1cd52c00dd::$classMap;
|
||||
$loader->prefixLengthsPsr4 = ComposerStaticInit3c4b06edaaaca82bbe48a07d10a1d2cb::$prefixLengthsPsr4;
|
||||
$loader->prefixDirsPsr4 = ComposerStaticInit3c4b06edaaaca82bbe48a07d10a1d2cb::$prefixDirsPsr4;
|
||||
$loader->classMap = ComposerStaticInit3c4b06edaaaca82bbe48a07d10a1d2cb::$classMap;
|
||||
|
||||
}, null, ClassLoader::class);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user