Updated Rector to commit 069e53a00efd322e8ab32b91938df894690b475c

069e53a00e [CodeQuality] Skip multiple assigns append before foreach on ForeachItemsAssignToEmptyArrayToAssignRector (#4052)
This commit is contained in:
Tomas Votruba 2023-06-02 22:04:35 +00:00
parent 26ee850893
commit 7823920f86
5 changed files with 37 additions and 12 deletions

View File

@ -5,11 +5,13 @@ namespace Rector\CodeQuality\Rector\Foreach_;
use PhpParser\Node;
use PhpParser\Node\Expr;
use PhpParser\Node\Expr\ArrayDimFetch;
use PhpParser\Node\Expr\Assign;
use PhpParser\Node\Expr\Variable;
use PhpParser\Node\Stmt;
use PhpParser\Node\Stmt\Expression;
use PhpParser\Node\Stmt\Foreach_;
use PhpParser\NodeTraverser;
use PHPStan\Analyser\Scope;
use Rector\CodeQuality\NodeAnalyzer\ForeachAnalyzer;
use Rector\Core\Contract\PhpParser\Node\StmtsAwareInterface;
@ -80,6 +82,9 @@ CODE_SAMPLE
if (\is_string($variableName)) {
$emptyArrayVariables[] = $variableName;
}
if ($this->isAppend($stmt, $emptyArrayVariables)) {
return null;
}
if (!$stmt instanceof Foreach_) {
continue;
}
@ -96,6 +101,26 @@ CODE_SAMPLE
}
return null;
}
/**
* @param string[] $emptyArrayVariables
*/
private function isAppend(Stmt $stmt, array $emptyArrayVariables) : bool
{
$isAppend = \false;
$this->traverseNodesWithCallable($stmt, function (Node $subNode) use($emptyArrayVariables, &$isAppend) : ?int {
if ($subNode instanceof Foreach_) {
return NodeTraverser::DONT_TRAVERSE_CURRENT_AND_CHILDREN;
}
if ($subNode instanceof Assign && $subNode->var instanceof ArrayDimFetch) {
$isAppend = $this->isNames($subNode->var->var, $emptyArrayVariables);
if ($isAppend) {
return NodeTraverser::STOP_TRAVERSAL;
}
}
return null;
});
return $isAppend;
}
/**
* @param string[] $emptyArrayVariables
*/

View File

@ -19,12 +19,12 @@ final class VersionResolver
* @api
* @var string
*/
public const PACKAGE_VERSION = '6dd57a913efe6fd5eb03542300b93cb1c22fc4dc';
public const PACKAGE_VERSION = '069e53a00efd322e8ab32b91938df894690b475c';
/**
* @api
* @var string
*/
public const RELEASE_DATE = '2023-06-02 14:05:22';
public const RELEASE_DATE = '2023-06-03 05:00:49';
/**
* @var int
*/

2
vendor/autoload.php vendored
View File

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

View File

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