Updated Rector to commit 7cde4132f7705a0f941867d66c909abd114e758d

7cde4132f7 Revert [Core] No need reindex FileWithoutNamespace on beforeTraverse (#4043) (#4044)
This commit is contained in:
Tomas Votruba 2023-06-02 07:37:33 +00:00
parent 633f196150
commit 26d8422934
25 changed files with 93 additions and 62 deletions

2
vendor/autoload.php vendored
View File

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

View File

@ -2,7 +2,7 @@
// autoload_real.php @generated by Composer
class ComposerAutoloaderInitd75ab83813f418bdfb24f57fa75cdab0
class ComposerAutoloaderInit645bfcab3009f9bdc8d78e18ba524ce6
{
private static $loader;
@ -22,17 +22,17 @@ class ComposerAutoloaderInitd75ab83813f418bdfb24f57fa75cdab0
return self::$loader;
}
spl_autoload_register(array('ComposerAutoloaderInitd75ab83813f418bdfb24f57fa75cdab0', 'loadClassLoader'), true, true);
spl_autoload_register(array('ComposerAutoloaderInit645bfcab3009f9bdc8d78e18ba524ce6', 'loadClassLoader'), true, true);
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__));
spl_autoload_unregister(array('ComposerAutoloaderInitd75ab83813f418bdfb24f57fa75cdab0', 'loadClassLoader'));
spl_autoload_unregister(array('ComposerAutoloaderInit645bfcab3009f9bdc8d78e18ba524ce6', 'loadClassLoader'));
require __DIR__ . '/autoload_static.php';
call_user_func(\Composer\Autoload\ComposerStaticInitd75ab83813f418bdfb24f57fa75cdab0::getInitializer($loader));
call_user_func(\Composer\Autoload\ComposerStaticInit645bfcab3009f9bdc8d78e18ba524ce6::getInitializer($loader));
$loader->setClassMapAuthoritative(true);
$loader->register(true);
$filesToLoad = \Composer\Autoload\ComposerStaticInitd75ab83813f418bdfb24f57fa75cdab0::$files;
$filesToLoad = \Composer\Autoload\ComposerStaticInit645bfcab3009f9bdc8d78e18ba524ce6::$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 ComposerStaticInitd75ab83813f418bdfb24f57fa75cdab0
class ComposerStaticInit645bfcab3009f9bdc8d78e18ba524ce6
{
public static $files = array (
'ad155f8f1cf0d418fe49e248db8c661b' => __DIR__ . '/..' . '/react/promise/src/functions_include.php',
@ -3066,9 +3066,9 @@ class ComposerStaticInitd75ab83813f418bdfb24f57fa75cdab0
public static function getInitializer(ClassLoader $loader)
{
return \Closure::bind(function () use ($loader) {
$loader->prefixLengthsPsr4 = ComposerStaticInitd75ab83813f418bdfb24f57fa75cdab0::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInitd75ab83813f418bdfb24f57fa75cdab0::$prefixDirsPsr4;
$loader->classMap = ComposerStaticInitd75ab83813f418bdfb24f57fa75cdab0::$classMap;
$loader->prefixLengthsPsr4 = ComposerStaticInit645bfcab3009f9bdc8d78e18ba524ce6::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInit645bfcab3009f9bdc8d78e18ba524ce6::$prefixDirsPsr4;
$loader->classMap = ComposerStaticInit645bfcab3009f9bdc8d78e18ba524ce6::$classMap;
}, null, ClassLoader::class);
}

View File

@ -1921,12 +1921,12 @@
"source": {
"type": "git",
"url": "https:\/\/github.com\/rectorphp\/rector-downgrade-php.git",
"reference": "c30399fe8bed067840e58ab67d6469c69ec59b28"
"reference": "f89da21c98b0b166571e334df6be0dd09d3721de"
},
"dist": {
"type": "zip",
"url": "https:\/\/api.github.com\/repos\/rectorphp\/rector-downgrade-php\/zipball\/c30399fe8bed067840e58ab67d6469c69ec59b28",
"reference": "c30399fe8bed067840e58ab67d6469c69ec59b28",
"url": "https:\/\/api.github.com\/repos\/rectorphp\/rector-downgrade-php\/zipball\/f89da21c98b0b166571e334df6be0dd09d3721de",
"reference": "f89da21c98b0b166571e334df6be0dd09d3721de",
"shasum": ""
},
"require": {
@ -1950,7 +1950,7 @@
"tomasvotruba\/type-coverage": "^0.2",
"tomasvotruba\/unused-public": "^0.1"
},
"time": "2023-06-02T03:54:09+00:00",
"time": "2023-06-02T07:33:34+00:00",
"default-branch": true,
"type": "rector-extension",
"extra": {

File diff suppressed because one or more lines are too long

View File

@ -9,7 +9,7 @@ namespace Rector\RectorInstaller;
*/
final class GeneratedConfig
{
public const EXTENSIONS = array('rector/rector-doctrine' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-doctrine', 'relative_install_path' => '../../rector-doctrine', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main 7f0656f'), 'rector/rector-downgrade-php' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-downgrade-php', 'relative_install_path' => '../../rector-downgrade-php', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main c30399f'), 'rector/rector-phpunit' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-phpunit', 'relative_install_path' => '../../rector-phpunit', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main b980109'), 'rector/rector-symfony' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-symfony', 'relative_install_path' => '../../rector-symfony', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main 13f7cc4'));
public const EXTENSIONS = array('rector/rector-doctrine' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-doctrine', 'relative_install_path' => '../../rector-doctrine', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main 7f0656f'), 'rector/rector-downgrade-php' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-downgrade-php', 'relative_install_path' => '../../rector-downgrade-php', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main f89da21'), 'rector/rector-phpunit' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-phpunit', 'relative_install_path' => '../../rector-phpunit', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main b980109'), 'rector/rector-symfony' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-symfony', 'relative_install_path' => '../../rector-symfony', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main 13f7cc4'));
private function __construct()
{
}

View File

@ -55,7 +55,8 @@ CODE_SAMPLE
}
private function getLevelsRealValue(FuncCall $funcCall) : ?int
{
$levelsArg = $funcCall->getArgs()[1] ?? null;
$args = $funcCall->getArgs();
$levelsArg = $args[1] ?? null;
if (!$levelsArg instanceof Arg) {
return null;
}

View File

@ -57,11 +57,12 @@ CODE_SAMPLE
if ($this->shouldSkip($node)) {
return null;
}
if (!isset($node->getArgs()[0])) {
$args = $node->getArgs();
if (!isset($args[0])) {
return null;
}
/** @var Array_ $options */
$options = $node->getArgs()[0]->value;
$options = $args[0]->value;
foreach ($options->items as $option) {
if (!$option instanceof ArrayItem) {
return null;
@ -85,9 +86,10 @@ CODE_SAMPLE
if (!$this->isName($funcCall, 'session_start')) {
return \true;
}
if (!isset($funcCall->getArgs()[0])) {
$args = $funcCall->getArgs();
if (!isset($args[0])) {
return \true;
}
return !$funcCall->getArgs()[0]->value instanceof Array_;
return !$args[0]->value instanceof Array_;
}
}

View File

@ -86,7 +86,8 @@ CODE_SAMPLE
if (!$this->isNotDirectlyCallableInPhp5($node->name)) {
return null;
}
$args = \array_merge([new Arg($node->name)], $node->getArgs());
$args = $node->getArgs();
$args = \array_merge([new Arg($node->name)], $args);
return new FuncCall(new Name('call_user_func'), $args);
}
private function isNotDirectlyCallableInPhp5(Expr $expr) : bool

View File

@ -58,7 +58,8 @@ CODE_SAMPLE
return null;
}
$methodCall = $this->createBindToCall($node);
$item1Unpacked = \array_slice($node->getArgs(), 1);
$args = $node->getArgs();
$item1Unpacked = \array_slice($args, 1);
$args = \array_merge([new Arg($methodCall)], $item1Unpacked);
return new FuncCall(new Name('call_user_func'), $args);
}
@ -71,7 +72,8 @@ CODE_SAMPLE
}
private function createBindToCall(MethodCall $methodCall) : MethodCall
{
$newObj = $methodCall->getArgs()[0];
$args = $methodCall->getArgs();
$newObj = $args[0];
if ($newObj->value instanceof Variable) {
$args = [$newObj, $newObj];
} else {

View File

@ -121,7 +121,8 @@ CODE_SAMPLE
$class = $this->classFromAnonymousFactory->create($className, $node->class);
$this->classes[] = $class;
$this->namespacedNameDecorator->decorate($class);
return new New_(new Name($className), $node->getArgs());
$args = $node->getArgs();
return new New_(new Name($className), $args);
}
private function createAnonymousClassName() : string
{

View File

@ -55,10 +55,11 @@ CODE_SAMPLE
if (!$this->isName($node, 'is_iterable')) {
return null;
}
if (!isset($node->getArgs()[0])) {
$args = $node->getArgs();
if (!isset($args[0])) {
return null;
}
$expr = $node->getArgs()[0]->value;
$expr = $args[0]->value;
$funcCall = $this->nodeFactory->createFuncCall('is_array', [$expr]);
$instanceof = new Instanceof_($expr, new FullyQualified('Traversable'));
return new BooleanOr($funcCall, $instanceof);

View File

@ -73,11 +73,12 @@ CODE_SAMPLE
if ($this->shouldSkipStaticCall($staticCall)) {
return null;
}
if (!isset($staticCall->getArgs()[0])) {
$args = $staticCall->getArgs();
if (!isset($args[0])) {
return null;
}
$tempVariable = $this->namedVariableFactory->createVariable($staticCall, 'callable');
$assignExpression = new Expression(new Assign($tempVariable, $staticCall->getArgs()[0]->value));
$assignExpression = new Expression(new Assign($tempVariable, $args[0]->value));
$innerFuncCall = new FuncCall($tempVariable, [new Arg($this->nodeFactory->createFuncCall('func_get_args'), \false, \true)]);
$closure = new Closure();
$closure->uses[] = new ClosureUse($tempVariable);
@ -97,11 +98,12 @@ CODE_SAMPLE
if ($this->shouldSkipStaticCall($staticCall)) {
return null;
}
if (!isset($staticCall->getArgs()[0])) {
$args = $staticCall->getArgs();
if (!isset($args[0])) {
return null;
}
$tempVariable = $this->namedVariableFactory->createVariable($staticCall, 'callable');
$assignExpression = new Expression(new Assign($tempVariable, $staticCall->getArgs()[0]->value));
$assignExpression = new Expression(new Assign($tempVariable, $args[0]->value));
$innerFuncCall = new FuncCall($tempVariable, [new Arg($this->nodeFactory->createFuncCall('func_get_args'), \false, \true)]);
$closure = new Closure();
$closure->uses[] = new ClosureUse($tempVariable);

View File

@ -46,9 +46,10 @@ final class FunctionExistsFunCallAnalyzer
}
/** @var FuncCall $functionExists */
$functionExists = $firstParentIf->cond;
if (!isset($functionExists->getArgs()[0])) {
$args = $functionExists->getArgs();
if (!isset($args[0])) {
return \false;
}
return $this->valueResolver->isValue($functionExists->getArgs()[0]->value, $functionName);
return $this->valueResolver->isValue($args[0]->value, $functionName);
}
}

View File

@ -50,7 +50,8 @@ final class BitwiseFlagCleaner
} elseif ($bitwiseOr->left instanceof ConstFetch && $this->nodeNameResolver->isName($bitwiseOr->left, $flag)) {
$bitwiseOr = $bitwiseOr->right;
}
$fourthArg = $funcCall->getArgs()[3] ?? null;
$args = $funcCall->getArgs();
$fourthArg = $args[3] ?? null;
if (!$fourthArg instanceof Arg) {
return;
}

View File

@ -119,7 +119,8 @@ CODE_SAMPLE
$variable = new Variable($this->variableNaming->createCountedValueName('streamIsatty', $scope));
$assign = new Assign($variable, $function);
$this->nodesToAddCollector->addNodeBeforeNode($assign, $node);
return new FuncCall($variable, $node->getArgs());
$args = $node->getArgs();
return new FuncCall($variable, $args);
}
private function createClosure() : Closure
{

View File

@ -125,10 +125,11 @@ CODE_SAMPLE
*/
private function refactorArrayKeyFirst(FuncCall $funcCall, $stmt, bool $isPartOfCond)
{
if (!isset($funcCall->getArgs()[0])) {
$args = $funcCall->getArgs();
if (!isset($args[0])) {
return null;
}
$originalArray = $funcCall->getArgs()[0]->value;
$originalArray = $args[0]->value;
$array = $this->resolveCastedArray($originalArray);
$newStmts = [];
if ($originalArray !== $array) {
@ -138,7 +139,7 @@ CODE_SAMPLE
$resetFuncCallExpression = new Expression($resetFuncCall);
$funcCall->name = new Name('key');
if ($originalArray !== $array) {
$firstArg = $funcCall->getArgs()[0];
$firstArg = $args[0];
$firstArg->value = $array;
}
if ($stmt instanceof StmtsAwareInterface && $isPartOfCond === \false) {
@ -154,7 +155,8 @@ CODE_SAMPLE
*/
private function refactorArrayKeyLast(FuncCall $funcCall, $stmt, bool $isPartOfCond)
{
$firstArg = $funcCall->getArgs()[0] ?? null;
$args = $funcCall->getArgs();
$firstArg = $args[0] ?? null;
if (!$firstArg instanceof Arg) {
return null;
}

View File

@ -45,11 +45,12 @@ CODE_SAMPLE
if (!$this->isName($node, 'is_countable')) {
return null;
}
if (!isset($node->getArgs()[0])) {
$args = $node->getArgs();
if (!isset($args[0])) {
return null;
}
$isArrayFuncCall = $this->nodeFactory->createFuncCall('is_array', $node->getArgs());
$instanceof = new Instanceof_($node->getArgs()[0]->value, new FullyQualified('Countable'));
$isArrayFuncCall = $this->nodeFactory->createFuncCall('is_array', $args);
$instanceof = new Instanceof_($args[0]->value, new FullyQualified('Countable'));
return new BooleanOr($isArrayFuncCall, $instanceof);
}
}

View File

@ -67,10 +67,14 @@ CODE_SAMPLE
*/
public function refactor(Node $node) : ?Node
{
if ($node->getArgs() !== []) {
\end($node->getArgs());
$lastArgumentPosition = \key($node->getArgs());
$last = $node->getArgs()[$lastArgumentPosition];
if ($node->isFirstClassCallable()) {
return null;
}
$args = $node->getArgs();
if ($args !== []) {
\end($args);
$lastArgumentPosition = \key($args);
$last = $args[$lastArgumentPosition];
if (!$this->followedByCommaAnalyzer->isFollowed($this->file, $last)) {
return null;
}

View File

@ -66,10 +66,14 @@ CODE_SAMPLE
if (!$this->isNames($funcCall, ['setcookie', 'setrawcookie'])) {
return \true;
}
if (\count($funcCall->getArgs()) < 3) {
if ($funcCall->isFirstClassCallable()) {
return \true;
}
$thirdArg = $funcCall->getArgs()[2];
$args = $funcCall->getArgs();
if (\count($args) < 3) {
return \true;
}
$thirdArg = $args[2];
return !$thirdArg->value instanceof Array_;
}
/**
@ -78,13 +82,14 @@ CODE_SAMPLE
private function composeNewArgs(FuncCall $funcCall) : array
{
$this->highestIndex = 1;
if (\count($funcCall->getArgs()) < 3) {
$args = $funcCall->getArgs();
if (\count($args) < 3) {
return [];
}
$firstArg = $funcCall->getArgs()[0];
$secondArg = $funcCall->getArgs()[1];
$firstArg = $args[0];
$secondArg = $args[1];
$newArgs = [$firstArg, $secondArg];
$thirdArg = $funcCall->getArgs()[2];
$thirdArg = $args[2];
/** @var Array_ $optionsArray */
$optionsArray = $thirdArg->value;
foreach ($optionsArray->items as $arrayItem) {

View File

@ -99,7 +99,8 @@ CODE_SAMPLE
if ($this->shouldSkipFuncCall($node)) {
return null;
}
$secondArg = $node->getArgs()[1];
$args = $node->getArgs();
$secondArg = $args[1];
$allowableTagsParam = $secondArg->value;
if ($allowableTagsParam instanceof Array_) {
// If it is an array, convert it to string
@ -131,11 +132,12 @@ CODE_SAMPLE
if (\count($funcCall->args) < 2) {
return \true;
}
if (!isset($funcCall->getArgs()[1])) {
$args = $funcCall->getArgs();
if (!isset($args[1])) {
return \true;
}
// Process anything other than String and null (eg: variables, function calls)
$allowableTagsParam = $funcCall->getArgs()[1]->value;
$allowableTagsParam = $args[1]->value;
// Skip for string
if ($allowableTagsParam instanceof String_) {
return \true;

View File

@ -57,11 +57,12 @@ CODE_SAMPLE
if (!$funcCall instanceof FuncCall) {
return null;
}
if (\count($funcCall->getArgs()) < 2) {
$args = $funcCall->getArgs();
if (\count($args) < 2) {
return null;
}
$haystack = $funcCall->getArgs()[0]->value;
$needle = $funcCall->getArgs()[1]->value;
$haystack = $args[0]->value;
$needle = $args[1]->value;
$funcCall = $this->nodeFactory->createFuncCall('strpos', [$haystack, $needle]);
if ($node instanceof BooleanNot) {
return new Identical($funcCall, $this->nodeFactory->createFalse());

View File

@ -78,10 +78,11 @@ final class ObjectToResourceReturn
if (!$this->nodeNameResolver->isName($subNode->name, 'is_resource')) {
return \false;
}
if (!isset($subNode->getArgs()[0])) {
$args = $subNode->getArgs();
if (!isset($args[0])) {
return \false;
}
return $this->nodeComparator->areNodesEqual($subNode->getArgs()[0], $expr);
return $this->nodeComparator->areNodesEqual($args[0], $expr);
});
}
return \false;

View File

@ -101,7 +101,8 @@ CODE_SAMPLE
$function = $this->createClosure();
$expression = new Expression(new Assign($variable, $function));
$this->nodesToAddCollector->addNodeBeforeNode($expression, $node);
return new FuncCall($variable, $node->getArgs());
$args = $node->getArgs();
return new FuncCall($variable, $args);
}
private function createClosure() : Closure
{

View File

@ -92,7 +92,8 @@ CODE_SAMPLE
$function = $this->createClosure();
$expression = new Expression(new Assign($variable, $function));
$this->nodesToAddCollector->addNodeBeforeNode($expression, $node);
return new FuncCall($variable, $node->getArgs());
$args = $node->getArgs();
return new FuncCall($variable, $args);
}
private function createClosure() : Closure
{