Updated Rector to commit 5f9adb646f

5f9adb646f [DeadCode] Skip RemoveUnusedPrivatePropertyRector on used in Assign expr (#1214)
This commit is contained in:
Tomas Votruba 2021-11-11 15:47:08 +00:00
parent 644c3edc59
commit 142542650d
6 changed files with 46 additions and 22 deletions

View File

@ -67,6 +67,8 @@ final class ComplexNodeRemover
{
$shouldKeepProperty = \false;
$propertyFetches = $this->propertyFetchFinder->findPrivatePropertyFetches($property);
$assigns = [];
$propertyNames = [];
foreach ($propertyFetches as $propertyFetch) {
if ($this->shouldSkipPropertyForClassMethod($propertyFetch, $classMethodNamesToSkip)) {
$shouldKeepProperty = \true;
@ -76,10 +78,11 @@ final class ComplexNodeRemover
if (!$assign instanceof \PhpParser\Node\Expr\Assign) {
return;
}
// remove assigns
$this->assignRemover->removeAssignNode($assign);
$this->removeConstructorDependency($assign);
$propertyName = (string) $this->nodeNameResolver->getName($propertyFetch);
$propertyNames[] = $propertyName;
$assigns[$propertyName][] = $assign;
}
$this->processRemovePropertyAssigns($assigns, $propertyNames);
if ($shouldKeepProperty) {
return;
}
@ -94,6 +97,21 @@ final class ComplexNodeRemover
}
$this->nodeRemover->removeNode($property);
}
/**
* @param array<string, Assign[]> $assigns
* @param string[] $propertyNames
*/
private function processRemovePropertyAssigns(array $assigns, array $propertyNames) : void
{
$propertyNames = \array_unique($propertyNames);
foreach ($propertyNames as $propertyName) {
foreach ($assigns[$propertyName] as $propertyNameAssign) {
// remove assigns
$this->assignRemover->removeAssignNode($propertyNameAssign);
$this->removeConstructorDependency($propertyNameAssign);
}
}
}
/**
* @param string[] $classMethodNamesToSkip
* @param \PhpParser\Node\Expr\PropertyFetch|\PhpParser\Node\Expr\StaticPropertyFetch $expr
@ -119,6 +137,12 @@ final class ComplexNodeRemover
if (!$assign instanceof \PhpParser\Node\Expr\Assign) {
return null;
}
$isInExpr = (bool) $this->betterNodeFinder->findFirst($assign->expr, function (\PhpParser\Node $subNode) use($expr) : bool {
return $this->nodeComparator->areNodesEqual($subNode, $expr);
});
if ($isInExpr) {
return null;
}
return $assign;
}
private function removeConstructorDependency(\PhpParser\Node\Expr\Assign $assign) : void

View File

@ -16,11 +16,11 @@ final class VersionResolver
/**
* @var string
*/
public const PACKAGE_VERSION = '34789896c513121a789aed7ecb5410f305f30c63';
public const PACKAGE_VERSION = '5f9adb646fc9d473ae658324da4010077e7311a4';
/**
* @var string
*/
public const RELEASE_DATE = '2021-11-11 15:13:17';
public const RELEASE_DATE = '2021-11-11 16:31:06';
public static function resolvePackageVersion() : string
{
$process = new \RectorPrefix20211111\Symfony\Component\Process\Process(['git', 'log', '--pretty="%H"', '-n1', 'HEAD'], __DIR__);

2
vendor/autoload.php vendored
View File

@ -4,4 +4,4 @@
require_once __DIR__ . '/composer/autoload_real.php';
return ComposerAutoloaderInit1ab64552102f75c029a8c6a897bfbc94::getLoader();
return ComposerAutoloaderInit8fb80e6086dda10c46c220d65da640f4::getLoader();

View File

@ -2,7 +2,7 @@
// autoload_real.php @generated by Composer
class ComposerAutoloaderInit1ab64552102f75c029a8c6a897bfbc94
class ComposerAutoloaderInit8fb80e6086dda10c46c220d65da640f4
{
private static $loader;
@ -22,15 +22,15 @@ class ComposerAutoloaderInit1ab64552102f75c029a8c6a897bfbc94
return self::$loader;
}
spl_autoload_register(array('ComposerAutoloaderInit1ab64552102f75c029a8c6a897bfbc94', 'loadClassLoader'), true, true);
spl_autoload_register(array('ComposerAutoloaderInit8fb80e6086dda10c46c220d65da640f4', 'loadClassLoader'), true, true);
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(\dirname(__FILE__)));
spl_autoload_unregister(array('ComposerAutoloaderInit1ab64552102f75c029a8c6a897bfbc94', 'loadClassLoader'));
spl_autoload_unregister(array('ComposerAutoloaderInit8fb80e6086dda10c46c220d65da640f4', 'loadClassLoader'));
$useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded());
if ($useStaticLoader) {
require __DIR__ . '/autoload_static.php';
call_user_func(\Composer\Autoload\ComposerStaticInit1ab64552102f75c029a8c6a897bfbc94::getInitializer($loader));
call_user_func(\Composer\Autoload\ComposerStaticInit8fb80e6086dda10c46c220d65da640f4::getInitializer($loader));
} else {
$classMap = require __DIR__ . '/autoload_classmap.php';
if ($classMap) {
@ -42,19 +42,19 @@ class ComposerAutoloaderInit1ab64552102f75c029a8c6a897bfbc94
$loader->register(true);
if ($useStaticLoader) {
$includeFiles = Composer\Autoload\ComposerStaticInit1ab64552102f75c029a8c6a897bfbc94::$files;
$includeFiles = Composer\Autoload\ComposerStaticInit8fb80e6086dda10c46c220d65da640f4::$files;
} else {
$includeFiles = require __DIR__ . '/autoload_files.php';
}
foreach ($includeFiles as $fileIdentifier => $file) {
composerRequire1ab64552102f75c029a8c6a897bfbc94($fileIdentifier, $file);
composerRequire8fb80e6086dda10c46c220d65da640f4($fileIdentifier, $file);
}
return $loader;
}
}
function composerRequire1ab64552102f75c029a8c6a897bfbc94($fileIdentifier, $file)
function composerRequire8fb80e6086dda10c46c220d65da640f4($fileIdentifier, $file)
{
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
require $file;

View File

@ -4,7 +4,7 @@
namespace Composer\Autoload;
class ComposerStaticInit1ab64552102f75c029a8c6a897bfbc94
class ComposerStaticInit8fb80e6086dda10c46c220d65da640f4
{
public static $files = array (
'a4a119a56e50fbb293281d9a48007e0e' => __DIR__ . '/..' . '/symfony/polyfill-php80/bootstrap.php',
@ -3535,9 +3535,9 @@ class ComposerStaticInit1ab64552102f75c029a8c6a897bfbc94
public static function getInitializer(ClassLoader $loader)
{
return \Closure::bind(function () use ($loader) {
$loader->prefixLengthsPsr4 = ComposerStaticInit1ab64552102f75c029a8c6a897bfbc94::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInit1ab64552102f75c029a8c6a897bfbc94::$prefixDirsPsr4;
$loader->classMap = ComposerStaticInit1ab64552102f75c029a8c6a897bfbc94::$classMap;
$loader->prefixLengthsPsr4 = ComposerStaticInit8fb80e6086dda10c46c220d65da640f4::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInit8fb80e6086dda10c46c220d65da640f4::$prefixDirsPsr4;
$loader->classMap = ComposerStaticInit8fb80e6086dda10c46c220d65da640f4::$classMap;
}, null, ClassLoader::class);
}

View File

@ -12,8 +12,8 @@ if (!class_exists('GenerateChangelogCommand', false) && !interface_exists('Gener
if (!class_exists('AutoloadIncluder', false) && !interface_exists('AutoloadIncluder', false) && !trait_exists('AutoloadIncluder', false)) {
spl_autoload_call('RectorPrefix20211111\AutoloadIncluder');
}
if (!class_exists('ComposerAutoloaderInit1ab64552102f75c029a8c6a897bfbc94', false) && !interface_exists('ComposerAutoloaderInit1ab64552102f75c029a8c6a897bfbc94', false) && !trait_exists('ComposerAutoloaderInit1ab64552102f75c029a8c6a897bfbc94', false)) {
spl_autoload_call('RectorPrefix20211111\ComposerAutoloaderInit1ab64552102f75c029a8c6a897bfbc94');
if (!class_exists('ComposerAutoloaderInit8fb80e6086dda10c46c220d65da640f4', false) && !interface_exists('ComposerAutoloaderInit8fb80e6086dda10c46c220d65da640f4', false) && !trait_exists('ComposerAutoloaderInit8fb80e6086dda10c46c220d65da640f4', false)) {
spl_autoload_call('RectorPrefix20211111\ComposerAutoloaderInit8fb80e6086dda10c46c220d65da640f4');
}
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('RectorPrefix20211111\Helmich\TypoScriptParser\Parser\AST\Statement');
@ -3309,9 +3309,9 @@ if (!function_exists('print_node')) {
return \RectorPrefix20211111\print_node(...func_get_args());
}
}
if (!function_exists('composerRequire1ab64552102f75c029a8c6a897bfbc94')) {
function composerRequire1ab64552102f75c029a8c6a897bfbc94() {
return \RectorPrefix20211111\composerRequire1ab64552102f75c029a8c6a897bfbc94(...func_get_args());
if (!function_exists('composerRequire8fb80e6086dda10c46c220d65da640f4')) {
function composerRequire8fb80e6086dda10c46c220d65da640f4() {
return \RectorPrefix20211111\composerRequire8fb80e6086dda10c46c220d65da640f4(...func_get_args());
}
}
if (!function_exists('parseArgs')) {