Updated Rector to commit 4ea7d0f477ff10755172869818056824b2d42dcd

4ea7d0f477 [DeadCode] Clean up PHPStan notice on ComplexNodeRemover::processRemoveParamWithKeys() (#4018)
This commit is contained in:
Tomas Votruba 2023-05-29 13:28:38 +00:00
parent e4e5a9d57d
commit 8925a6a4f0
8 changed files with 76 additions and 49 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 ComposerAutoloaderInitaba6a07e9e8446a4a6f1d32b3e74272b::getLoader();
return ComposerAutoloaderInit1129ecb5f2bd2dbc397346f31cbc7d99::getLoader();

View File

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

View File

@ -2059,12 +2059,12 @@
"source": {
"type": "git",
"url": "https:\/\/github.com\/rectorphp\/rector-symfony.git",
"reference": "3878c8837ef2ca76b58601a3132f7da9ae87c044"
"reference": "15475fc5a3d2f0f66e417ff78695f06de8a9d5b3"
},
"dist": {
"type": "zip",
"url": "https:\/\/api.github.com\/repos\/rectorphp\/rector-symfony\/zipball\/3878c8837ef2ca76b58601a3132f7da9ae87c044",
"reference": "3878c8837ef2ca76b58601a3132f7da9ae87c044",
"url": "https:\/\/api.github.com\/repos\/rectorphp\/rector-symfony\/zipball\/15475fc5a3d2f0f66e417ff78695f06de8a9d5b3",
"reference": "15475fc5a3d2f0f66e417ff78695f06de8a9d5b3",
"shasum": ""
},
"require": {
@ -2094,7 +2094,7 @@
"tomasvotruba\/type-coverage": "^0.0.9",
"tomasvotruba\/unused-public": "^0.0.34"
},
"time": "2023-05-26T23:58:27+00:00",
"time": "2023-05-29T13:18:20+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 7e3df08'), '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 abf0a7f'), '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 edbdd0e'), '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 3878c88'));
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 7e3df08'), '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 abf0a7f'), '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 edbdd0e'), '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 15475fc'));
private function __construct()
{
}

View File

@ -12,6 +12,7 @@ use PhpParser\Node\Name;
use PhpParser\Node\Scalar\String_;
use PhpParser\Node\Stmt\Class_;
use PhpParser\Node\Stmt\ClassMethod;
use PhpParser\Node\Stmt\Expression;
use PhpParser\NodeTraverser;
use PHPStan\Type\ObjectType;
use Rector\NodeNameResolver\NodeNameResolver;
@ -59,41 +60,35 @@ final class CommandHelper
$this->simpleCallableNodeTraverser = $simpleCallableNodeTraverser;
$this->nodeRemover = $nodeRemover;
}
public function getCommandAliasesValueFromAttributeOrSetter(Class_ $class) : ?Array_
public function resolveCommandAliasesFromAttributeOrSetter(Class_ $class) : ?Array_
{
$commandAliases = null;
$classMethod = $class->getMethod('configure');
if (!$classMethod instanceof ClassMethod) {
return $this->resolveAliasesFromAttribute($class);
return $this->resolveCommandAliasesFromAttribute($class);
}
$this->simpleCallableNodeTraverser->traverseNodesWithCallable((array) $classMethod->stmts, function (Node $node) use(&$commandAliases) {
if ($classMethod->stmts === null) {
return null;
}
$aliasesArray = $this->resolveFromStmtSetterMethodCall($classMethod);
if ($aliasesArray instanceof Array_) {
return $aliasesArray;
}
$aliasesArray = null;
$this->simpleCallableNodeTraverser->traverseNodesWithCallable($classMethod, function (Node $node) use(&$aliasesArray) {
if (!$node instanceof MethodCall) {
return null;
}
if ($node->isFirstClassCallable()) {
if (!$this->isSetAliasesMethodCall($node)) {
return null;
}
if (!$this->nodeNameResolver->isName($node->name, 'setAliases')) {
$firstArgValue = $node->getArgs()[0]->value;
if (!$firstArgValue instanceof Array_) {
return null;
}
if (!$this->nodeTypeResolver->isObjectType($node->var, new ObjectType('Symfony\\Component\\Console\\Command\\Command'))) {
return null;
}
/** @var Arg $arg */
$arg = $node->args[0];
if (!$arg->value instanceof Array_) {
return null;
}
$commandAliases = $arg->value;
$parentNode = $node->getAttribute(AttributeKey::PARENT_NODE);
if ($parentNode instanceof MethodCall) {
$parentNode->var = $node->var;
} else {
$this->nodeRemover->removeNode($node);
}
return NodeTraverser::STOP_TRAVERSAL;
$aliasesArray = $firstArgValue;
return $node->var;
});
return $commandAliases;
return $aliasesArray;
}
public function getCommandHiddenValueFromAttributeOrSetter(Class_ $class) : ?ConstFetch
{
@ -162,6 +157,13 @@ final class CommandHelper
}
return $argumentValue;
}
private function isSetAliasesMethodCall(MethodCall $methodCall) : bool
{
if (!$this->nodeNameResolver->isName($methodCall->name, 'setAliases')) {
return \false;
}
return $this->nodeTypeResolver->isObjectType($methodCall->var, new ObjectType('Symfony\\Component\\Console\\Command\\Command'));
}
private function resolveHiddenFromAttribute(Class_ $class) : ?ConstFetch
{
$commandHidden = null;
@ -173,15 +175,40 @@ final class CommandHelper
}
return $commandHidden;
}
private function resolveAliasesFromAttribute(Class_ $class) : ?Array_
private function resolveCommandAliasesFromAttribute(Class_ $class) : ?Array_
{
$commandAliases = null;
if ($this->phpAttributeAnalyzer->hasPhpAttribute($class, self::ATTRIBUTE)) {
$commandAliasesFromArgument = $this->getArgumentValueFromAttribute($class, 2);
if ($commandAliasesFromArgument instanceof Array_) {
$commandAliases = $commandAliasesFromArgument;
}
if (!$this->phpAttributeAnalyzer->hasPhpAttribute($class, self::ATTRIBUTE)) {
return null;
}
return $commandAliases;
$commandAliasesFromArgument = $this->getArgumentValueFromAttribute($class, 2);
if ($commandAliasesFromArgument instanceof Array_) {
return $commandAliasesFromArgument;
}
return null;
}
private function resolveFromStmtSetterMethodCall(ClassMethod $classMethod) : ?\PhpParser\Node\Expr\Array_
{
if ($classMethod->stmts === null) {
return null;
}
foreach ($classMethod->stmts as $key => $stmt) {
if (!$stmt instanceof Expression) {
continue;
}
if (!$stmt->expr instanceof MethodCall) {
continue;
}
$methodCall = $stmt->expr;
if (!$this->isSetAliasesMethodCall($methodCall)) {
continue;
}
$arg = $methodCall->getArgs()[0];
if (!$arg->value instanceof Array_) {
return null;
}
unset($classMethod->stmts[$key]);
return $arg->value;
}
return null;
}
}

View File

@ -105,9 +105,9 @@ CODE_SAMPLE
return null;
}
$defaultDescription = $this->resolveDefaultDescription($node);
$array = $this->commandHelper->getCommandAliasesValueFromAttributeOrSetter($node);
$alisesArray = $this->commandHelper->resolveCommandAliasesFromAttributeOrSetter($node);
$constFetch = $this->commandHelper->getCommandHiddenValueFromAttributeOrSetter($node);
return $this->replaceAsCommandAttribute($node, $this->createAttributeGroupAsCommand($defaultName, $defaultDescription, $array, $constFetch));
return $this->replaceAsCommandAttribute($node, $this->createAttributeGroupAsCommand($defaultName, $defaultDescription, $alisesArray, $constFetch));
}
private function createAttributeGroupAsCommand(string $defaultName, ?string $defaultDescription, ?Array_ $array, ?ConstFetch $constFetch) : AttributeGroup
{