Updated Rector to commit 24b9eb7a4cf97a05b66163545a9d315e0f15d7f5

24b9eb7a4c [Core] Refactor CreatedByRuleDecorator to make consistent check for consecutive same Rector run (#3078)
This commit is contained in:
Tomas Votruba 2022-11-19 07:50:13 +00:00
parent 87bf8a85b4
commit 141dc65509
6 changed files with 40 additions and 29 deletions

View File

@ -17,12 +17,12 @@ final class VersionResolver
* @api
* @var string
*/
public const PACKAGE_VERSION = '31bf9e468a1c271296236e6363a4d7e69f7f73c1';
public const PACKAGE_VERSION = '24b9eb7a4cf97a05b66163545a9d315e0f15d7f5';
/**
* @api
* @var string
*/
public const RELEASE_DATE = '2022-11-18 22:01:50';
public const RELEASE_DATE = '2022-11-19 14:43:58';
/**
* @var int
*/

View File

@ -24,8 +24,22 @@ final class CreatedByRuleDecorator
}
private function createByRule(Node $node, string $rectorClass) : void
{
$mergeCreatedByRule = \array_merge($node->getAttribute(AttributeKey::CREATED_BY_RULE) ?? [], [$rectorClass]);
$mergeCreatedByRule = \array_unique($mergeCreatedByRule);
$node->setAttribute(AttributeKey::CREATED_BY_RULE, $mergeCreatedByRule);
$createdByRule = $node->getAttribute(AttributeKey::CREATED_BY_RULE) ?? [];
\end($createdByRule);
$lastRectorRuleKey = \key($createdByRule);
// empty array, insert
if ($lastRectorRuleKey === null) {
$node->setAttribute(AttributeKey::CREATED_BY_RULE, [$rectorClass]);
return;
}
// consecutive, no need to refill
if ($createdByRule[$lastRectorRuleKey] === $rectorClass) {
return;
}
// filter out when exists, then append
$createdByRule = \array_filter($createdByRule, static function (string $rectorRule) use($rectorClass) : bool {
return $rectorRule !== $rectorClass;
});
$node->setAttribute(AttributeKey::CREATED_BY_RULE, \array_merge(\is_array($createdByRule) ? $createdByRule : \iterator_to_array($createdByRule), [$rectorClass]));
}
}

View File

@ -36,7 +36,7 @@ final class RectifiedAnalyzer
public function verify(string $rectorClass, Node $node, string $filePath) : ?RectifiedNode
{
$originalNode = $node->getAttribute(AttributeKey::ORIGINAL_NODE);
if ($this->hasCreatedByRule($rectorClass, $node, $originalNode)) {
if ($this->hasConsecutiveCreatedByRule($rectorClass, $node, $originalNode)) {
return new RectifiedNode($rectorClass, $node);
}
if (!isset($this->previousFileWithNodes[$filePath])) {
@ -57,19 +57,16 @@ final class RectifiedAnalyzer
/**
* @param class-string<RectorInterface> $rectorClass
*/
private function hasCreatedByRule(string $rectorClass, Node $node, ?Node $originalNode) : bool
private function hasConsecutiveCreatedByRule(string $rectorClass, Node $node, ?Node $originalNode) : bool
{
if (!$originalNode instanceof Node) {
$createdByRule = $node->getAttribute(AttributeKey::CREATED_BY_RULE) ?? [];
\end($createdByRule);
$lastRectorRuleKey = \key($createdByRule);
if ($lastRectorRuleKey === null) {
return \false;
}
return $createdByRule[$lastRectorRuleKey] === $rectorClass;
$createdByRuleNode = $originalNode ?? $node;
$createdByRule = $createdByRuleNode->getAttribute(AttributeKey::CREATED_BY_RULE) ?? [];
\end($createdByRule);
$lastRectorRuleKey = \key($createdByRule);
if ($lastRectorRuleKey === null) {
return \false;
}
$createdByRule = $originalNode->getAttribute(AttributeKey::CREATED_BY_RULE) ?? [];
return \in_array($rectorClass, $createdByRule, \true);
return $createdByRule[$lastRectorRuleKey] === $rectorClass;
}
/**
* @param class-string<RectorInterface> $rectorClass

2
vendor/autoload.php vendored
View File

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

View File

@ -2,7 +2,7 @@
// autoload_real.php @generated by Composer
class ComposerAutoloaderInit9b2c989c5b251fa527a9c379f687a500
class ComposerAutoloaderInit0a4ebefb5579274df6d9b429a62144d3
{
private static $loader;
@ -22,19 +22,19 @@ class ComposerAutoloaderInit9b2c989c5b251fa527a9c379f687a500
return self::$loader;
}
spl_autoload_register(array('ComposerAutoloaderInit9b2c989c5b251fa527a9c379f687a500', 'loadClassLoader'), true, true);
spl_autoload_register(array('ComposerAutoloaderInit0a4ebefb5579274df6d9b429a62144d3', 'loadClassLoader'), true, true);
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__));
spl_autoload_unregister(array('ComposerAutoloaderInit9b2c989c5b251fa527a9c379f687a500', 'loadClassLoader'));
spl_autoload_unregister(array('ComposerAutoloaderInit0a4ebefb5579274df6d9b429a62144d3', 'loadClassLoader'));
require __DIR__ . '/autoload_static.php';
call_user_func(\Composer\Autoload\ComposerStaticInit9b2c989c5b251fa527a9c379f687a500::getInitializer($loader));
call_user_func(\Composer\Autoload\ComposerStaticInit0a4ebefb5579274df6d9b429a62144d3::getInitializer($loader));
$loader->setClassMapAuthoritative(true);
$loader->register(true);
$includeFiles = \Composer\Autoload\ComposerStaticInit9b2c989c5b251fa527a9c379f687a500::$files;
$includeFiles = \Composer\Autoload\ComposerStaticInit0a4ebefb5579274df6d9b429a62144d3::$files;
foreach ($includeFiles as $fileIdentifier => $file) {
composerRequire9b2c989c5b251fa527a9c379f687a500($fileIdentifier, $file);
composerRequire0a4ebefb5579274df6d9b429a62144d3($fileIdentifier, $file);
}
return $loader;
@ -46,7 +46,7 @@ class ComposerAutoloaderInit9b2c989c5b251fa527a9c379f687a500
* @param string $file
* @return void
*/
function composerRequire9b2c989c5b251fa527a9c379f687a500($fileIdentifier, $file)
function composerRequire0a4ebefb5579274df6d9b429a62144d3($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 ComposerStaticInit9b2c989c5b251fa527a9c379f687a500
class ComposerStaticInit0a4ebefb5579274df6d9b429a62144d3
{
public static $files = array (
'ad155f8f1cf0d418fe49e248db8c661b' => __DIR__ . '/..' . '/react/promise/src/functions_include.php',
@ -3034,9 +3034,9 @@ class ComposerStaticInit9b2c989c5b251fa527a9c379f687a500
public static function getInitializer(ClassLoader $loader)
{
return \Closure::bind(function () use ($loader) {
$loader->prefixLengthsPsr4 = ComposerStaticInit9b2c989c5b251fa527a9c379f687a500::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInit9b2c989c5b251fa527a9c379f687a500::$prefixDirsPsr4;
$loader->classMap = ComposerStaticInit9b2c989c5b251fa527a9c379f687a500::$classMap;
$loader->prefixLengthsPsr4 = ComposerStaticInit0a4ebefb5579274df6d9b429a62144d3::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInit0a4ebefb5579274df6d9b429a62144d3::$prefixDirsPsr4;
$loader->classMap = ComposerStaticInit0a4ebefb5579274df6d9b429a62144d3::$classMap;
}, null, ClassLoader::class);
}