Updated Rector to commit 36fe5d5d05eae7a4c0ce74513d378d80737c16c8

36fe5d5d05 [DeadCode] fix RemoveJustPropertyFetchForAssignRector for nested array dim fetch (#2427)
This commit is contained in:
Tomas Votruba 2022-06-04 09:21:35 +00:00
parent a086786382
commit d755df61c1
7 changed files with 36 additions and 55 deletions

View File

@ -38,9 +38,11 @@ final class JustPropertyFetchVariableAssignMatcher
if (!$thirdVariableAndPropertyFetchAssign instanceof \Rector\DeadCode\ValueObject\VariableAndPropertyFetchAssign) {
return null;
}
// property fetch are the same
if (!$this->nodeComparator->areNodesEqual($firstVariableAndPropertyFetchAssign->getPropertyFetch(), $thirdVariableAndPropertyFetchAssign->getPropertyFetch())) {
return null;
}
// variables are the same
if (!$this->nodeComparator->areNodesEqual($firstVariableAndPropertyFetchAssign->getVariable(), $thirdVariableAndPropertyFetchAssign->getVariable())) {
return null;
}

View File

@ -80,48 +80,27 @@ CODE_SAMPLE
return null;
}
$middleAssign = $secondStmt->expr;
if ($middleAssign->var instanceof \PhpParser\Node\Expr\Variable) {
return $this->refactorToVariableAssign($middleAssign, $variableAndPropertyFetchAssign, $node);
$assignVar = $middleAssign->var;
// unwrap all array dim fetch nesting
$lastArrayDimFetch = null;
while ($assignVar instanceof \PhpParser\Node\Expr\ArrayDimFetch) {
$lastArrayDimFetch = $assignVar;
$assignVar = $assignVar->var;
}
if ($middleAssign->var instanceof \PhpParser\Node\Expr\ArrayDimFetch) {
return $this->removeToArrayDimFetchAssign($middleAssign, $variableAndPropertyFetchAssign, $node);
}
return null;
}
/**
* @return \Rector\Core\Contract\PhpParser\Node\StmtsAwareInterface|\PhpParser\Node|null
*/
private function refactorToVariableAssign(\PhpParser\Node\Expr\Assign $middleAssign, \Rector\DeadCode\ValueObject\VariableAndPropertyFetchAssign $variableAndPropertyFetchAssign, \Rector\Core\Contract\PhpParser\Node\StmtsAwareInterface $stmtsAware)
{
$middleVariable = $middleAssign->var;
if (!$this->nodeComparator->areNodesEqual($middleVariable, $variableAndPropertyFetchAssign->getVariable())) {
if (!$assignVar instanceof \PhpParser\Node\Expr\Variable) {
return null;
}
// remove just-assign stmts
unset($stmtsAware->stmts[0]);
unset($stmtsAware->stmts[2]);
$middleAssign->var = $variableAndPropertyFetchAssign->getPropertyFetch();
return $stmtsAware;
}
/**
* @return \Rector\Core\Contract\PhpParser\Node\StmtsAwareInterface|null
*/
private function removeToArrayDimFetchAssign(\PhpParser\Node\Expr\Assign $middleAssign, \Rector\DeadCode\ValueObject\VariableAndPropertyFetchAssign $variableAndPropertyFetchAssign, \Rector\Core\Contract\PhpParser\Node\StmtsAwareInterface $stmtsAware)
{
$middleArrayDimFetch = $middleAssign->var;
if (!$middleArrayDimFetch instanceof \PhpParser\Node\Expr\ArrayDimFetch) {
if (!$this->nodeComparator->areNodesEqual($assignVar, $variableAndPropertyFetchAssign->getVariable())) {
return null;
}
if ($middleArrayDimFetch->var instanceof \PhpParser\Node\Expr\Variable) {
$middleNestedVariable = $middleArrayDimFetch->var;
if (!$this->nodeComparator->areNodesEqual($middleNestedVariable, $variableAndPropertyFetchAssign->getVariable())) {
return null;
}
$middleArrayDimFetch->var = $variableAndPropertyFetchAssign->getPropertyFetch();
if ($lastArrayDimFetch instanceof \PhpParser\Node\Expr\ArrayDimFetch) {
$lastArrayDimFetch->var = $variableAndPropertyFetchAssign->getPropertyFetch();
} else {
$middleAssign->var = $variableAndPropertyFetchAssign->getPropertyFetch();
}
// remove just-assign stmts
unset($stmtsAware->stmts[0]);
unset($stmtsAware->stmts[2]);
return $stmtsAware;
unset($node->stmts[0]);
unset($node->stmts[2]);
return $node;
}
}

View File

@ -16,11 +16,11 @@ final class VersionResolver
/**
* @var string
*/
public const PACKAGE_VERSION = 'f5e34f03934e833a80e1d22884978549715fccb3';
public const PACKAGE_VERSION = '36fe5d5d05eae7a4c0ce74513d378d80737c16c8';
/**
* @var string
*/
public const RELEASE_DATE = '2022-06-04 10:19:54';
public const RELEASE_DATE = '2022-06-04 09:15:02';
/**
* @var int
*/

2
vendor/autoload.php vendored
View File

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

View File

@ -2,7 +2,7 @@
// autoload_real.php @generated by Composer
class ComposerAutoloaderInitee26c5d6e69256f5e6aba1c07569ee23
class ComposerAutoloaderInit09940c5d03e63bc1beb715abf893e3a3
{
private static $loader;
@ -22,19 +22,19 @@ class ComposerAutoloaderInitee26c5d6e69256f5e6aba1c07569ee23
return self::$loader;
}
spl_autoload_register(array('ComposerAutoloaderInitee26c5d6e69256f5e6aba1c07569ee23', 'loadClassLoader'), true, true);
spl_autoload_register(array('ComposerAutoloaderInit09940c5d03e63bc1beb715abf893e3a3', 'loadClassLoader'), true, true);
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__));
spl_autoload_unregister(array('ComposerAutoloaderInitee26c5d6e69256f5e6aba1c07569ee23', 'loadClassLoader'));
spl_autoload_unregister(array('ComposerAutoloaderInit09940c5d03e63bc1beb715abf893e3a3', 'loadClassLoader'));
require __DIR__ . '/autoload_static.php';
call_user_func(\Composer\Autoload\ComposerStaticInitee26c5d6e69256f5e6aba1c07569ee23::getInitializer($loader));
call_user_func(\Composer\Autoload\ComposerStaticInit09940c5d03e63bc1beb715abf893e3a3::getInitializer($loader));
$loader->setClassMapAuthoritative(true);
$loader->register(true);
$includeFiles = \Composer\Autoload\ComposerStaticInitee26c5d6e69256f5e6aba1c07569ee23::$files;
$includeFiles = \Composer\Autoload\ComposerStaticInit09940c5d03e63bc1beb715abf893e3a3::$files;
foreach ($includeFiles as $fileIdentifier => $file) {
composerRequireee26c5d6e69256f5e6aba1c07569ee23($fileIdentifier, $file);
composerRequire09940c5d03e63bc1beb715abf893e3a3($fileIdentifier, $file);
}
return $loader;
@ -46,7 +46,7 @@ class ComposerAutoloaderInitee26c5d6e69256f5e6aba1c07569ee23
* @param string $file
* @return void
*/
function composerRequireee26c5d6e69256f5e6aba1c07569ee23($fileIdentifier, $file)
function composerRequire09940c5d03e63bc1beb715abf893e3a3($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 ComposerStaticInitee26c5d6e69256f5e6aba1c07569ee23
class ComposerStaticInit09940c5d03e63bc1beb715abf893e3a3
{
public static $files = array (
'0e6d7bf4a5811bfa5cf40c5ccd6fae6a' => __DIR__ . '/..' . '/symfony/polyfill-mbstring/bootstrap.php',
@ -3791,9 +3791,9 @@ class ComposerStaticInitee26c5d6e69256f5e6aba1c07569ee23
public static function getInitializer(ClassLoader $loader)
{
return \Closure::bind(function () use ($loader) {
$loader->prefixLengthsPsr4 = ComposerStaticInitee26c5d6e69256f5e6aba1c07569ee23::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInitee26c5d6e69256f5e6aba1c07569ee23::$prefixDirsPsr4;
$loader->classMap = ComposerStaticInitee26c5d6e69256f5e6aba1c07569ee23::$classMap;
$loader->prefixLengthsPsr4 = ComposerStaticInit09940c5d03e63bc1beb715abf893e3a3::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInit09940c5d03e63bc1beb715abf893e3a3::$prefixDirsPsr4;
$loader->classMap = ComposerStaticInit09940c5d03e63bc1beb715abf893e3a3::$classMap;
}, null, ClassLoader::class);
}

View File

@ -9,8 +9,8 @@ $loader = require_once __DIR__.'/autoload.php';
if (!class_exists('AutoloadIncluder', false) && !interface_exists('AutoloadIncluder', false) && !trait_exists('AutoloadIncluder', false)) {
spl_autoload_call('RectorPrefix20220604\AutoloadIncluder');
}
if (!class_exists('ComposerAutoloaderInitee26c5d6e69256f5e6aba1c07569ee23', false) && !interface_exists('ComposerAutoloaderInitee26c5d6e69256f5e6aba1c07569ee23', false) && !trait_exists('ComposerAutoloaderInitee26c5d6e69256f5e6aba1c07569ee23', false)) {
spl_autoload_call('RectorPrefix20220604\ComposerAutoloaderInitee26c5d6e69256f5e6aba1c07569ee23');
if (!class_exists('ComposerAutoloaderInit09940c5d03e63bc1beb715abf893e3a3', false) && !interface_exists('ComposerAutoloaderInit09940c5d03e63bc1beb715abf893e3a3', false) && !trait_exists('ComposerAutoloaderInit09940c5d03e63bc1beb715abf893e3a3', false)) {
spl_autoload_call('RectorPrefix20220604\ComposerAutoloaderInit09940c5d03e63bc1beb715abf893e3a3');
}
if (!class_exists('Helmich\TypoScriptParser\Parser\AST\Statement', false) && !interface_exists('Helmich\TypoScriptParser\Parser\AST\Statement', false) && !trait_exists('Helmich\TypoScriptParser\Parser\AST\Statement', false)) {
spl_autoload_call('RectorPrefix20220604\Helmich\TypoScriptParser\Parser\AST\Statement');
@ -59,9 +59,9 @@ if (!function_exists('print_node')) {
return \RectorPrefix20220604\print_node(...func_get_args());
}
}
if (!function_exists('composerRequireee26c5d6e69256f5e6aba1c07569ee23')) {
function composerRequireee26c5d6e69256f5e6aba1c07569ee23() {
return \RectorPrefix20220604\composerRequireee26c5d6e69256f5e6aba1c07569ee23(...func_get_args());
if (!function_exists('composerRequire09940c5d03e63bc1beb715abf893e3a3')) {
function composerRequire09940c5d03e63bc1beb715abf893e3a3() {
return \RectorPrefix20220604\composerRequire09940c5d03e63bc1beb715abf893e3a3(...func_get_args());
}
}
if (!function_exists('scanPath')) {