From b7c661cd457ffe114082623778a33589c0cfba5f Mon Sep 17 00:00:00 2001 From: Tomas Votruba Date: Sun, 22 May 2022 17:06:09 +0000 Subject: [PATCH] Updated Rector to commit a9c6d9bd06515b5e5bbbcad3b2f7e70d3ab59125 https://github.com/rectorphp/rector-src/commit/a9c6d9bd06515b5e5bbbcad3b2f7e70d3ab59125 [Core][DeadCode] Remove ClassMethodManipulator->isPropertyPromotion() (#2346) --- .../ClassMethod/RemoveDeadConstructorRector.php | 11 +++++++++-- .../ClassMethod/RemoveEmptyClassMethodRector.php | 11 +++++++++-- src/Application/VersionResolver.php | 4 ++-- src/NodeManipulator/ClassMethodManipulator.php | 10 ---------- vendor/autoload.php | 2 +- vendor/composer/autoload_real.php | 14 +++++++------- vendor/composer/autoload_static.php | 8 ++++---- vendor/scoper-autoload.php | 10 +++++----- 8 files changed, 37 insertions(+), 33 deletions(-) diff --git a/rules/DeadCode/Rector/ClassMethod/RemoveDeadConstructorRector.php b/rules/DeadCode/Rector/ClassMethod/RemoveDeadConstructorRector.php index 3c2b17aef120..ded560d3f8ec 100644 --- a/rules/DeadCode/Rector/ClassMethod/RemoveDeadConstructorRector.php +++ b/rules/DeadCode/Rector/ClassMethod/RemoveDeadConstructorRector.php @@ -7,6 +7,7 @@ use PhpParser\Node\Name\FullyQualified; use PhpParser\Node\Stmt\Class_; use PhpParser\Node\Stmt\ClassMethod; +use Rector\Core\NodeAnalyzer\ParamAnalyzer; use Rector\Core\NodeManipulator\ClassMethodManipulator; use Rector\Core\Rector\AbstractRector; use Rector\Core\ValueObject\MethodName; @@ -22,9 +23,15 @@ final class RemoveDeadConstructorRector extends \Rector\Core\Rector\AbstractRect * @var \Rector\Core\NodeManipulator\ClassMethodManipulator */ private $classMethodManipulator; - public function __construct(\Rector\Core\NodeManipulator\ClassMethodManipulator $classMethodManipulator) + /** + * @readonly + * @var \Rector\Core\NodeAnalyzer\ParamAnalyzer + */ + private $paramAnalyzer; + public function __construct(\Rector\Core\NodeManipulator\ClassMethodManipulator $classMethodManipulator, \Rector\Core\NodeAnalyzer\ParamAnalyzer $paramAnalyzer) { $this->classMethodManipulator = $classMethodManipulator; + $this->paramAnalyzer = $paramAnalyzer; } public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition { @@ -79,7 +86,7 @@ private function shouldSkipPropertyPromotion(\PhpParser\Node\Stmt\ClassMethod $c if ($classMethod->stmts !== []) { return \true; } - if ($this->classMethodManipulator->isPropertyPromotion($classMethod)) { + if ($this->paramAnalyzer->hasPropertyPromotion($classMethod->params)) { return \true; } return $this->classMethodManipulator->isNamedConstructor($classMethod); diff --git a/rules/DeadCode/Rector/ClassMethod/RemoveEmptyClassMethodRector.php b/rules/DeadCode/Rector/ClassMethod/RemoveEmptyClassMethodRector.php index 1140cc22fdb8..7263ea4c0a37 100644 --- a/rules/DeadCode/Rector/ClassMethod/RemoveEmptyClassMethodRector.php +++ b/rules/DeadCode/Rector/ClassMethod/RemoveEmptyClassMethodRector.php @@ -7,6 +7,7 @@ use PhpParser\Node\Name\FullyQualified; use PhpParser\Node\Stmt\Class_; use PhpParser\Node\Stmt\ClassMethod; +use Rector\Core\NodeAnalyzer\ParamAnalyzer; use Rector\Core\NodeManipulator\ClassMethodManipulator; use Rector\Core\Rector\AbstractRector; use Rector\Core\ValueObject\MethodName; @@ -28,10 +29,16 @@ final class RemoveEmptyClassMethodRector extends \Rector\Core\Rector\AbstractRec * @var \Rector\DeadCode\NodeManipulator\ControllerClassMethodManipulator */ private $controllerClassMethodManipulator; - public function __construct(\Rector\Core\NodeManipulator\ClassMethodManipulator $classMethodManipulator, \Rector\DeadCode\NodeManipulator\ControllerClassMethodManipulator $controllerClassMethodManipulator) + /** + * @readonly + * @var \Rector\Core\NodeAnalyzer\ParamAnalyzer + */ + private $paramAnalyzer; + public function __construct(\Rector\Core\NodeManipulator\ClassMethodManipulator $classMethodManipulator, \Rector\DeadCode\NodeManipulator\ControllerClassMethodManipulator $controllerClassMethodManipulator, \Rector\Core\NodeAnalyzer\ParamAnalyzer $paramAnalyzer) { $this->classMethodManipulator = $classMethodManipulator; $this->controllerClassMethodManipulator = $controllerClassMethodManipulator; + $this->paramAnalyzer = $paramAnalyzer; } public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition { @@ -105,7 +112,7 @@ private function shouldSkipClassMethod(\PhpParser\Node\Stmt\ClassMethod $classMe if ($this->classMethodManipulator->hasParentMethodOrInterfaceMethod($classMethod)) { return \true; } - if ($this->classMethodManipulator->isPropertyPromotion($classMethod)) { + if ($this->paramAnalyzer->hasPropertyPromotion($classMethod->params)) { return \true; } if ($this->controllerClassMethodManipulator->isControllerClassMethodWithBehaviorAnnotation($classMethod)) { diff --git a/src/Application/VersionResolver.php b/src/Application/VersionResolver.php index 24a6dd225a6d..ec5824197bde 100644 --- a/src/Application/VersionResolver.php +++ b/src/Application/VersionResolver.php @@ -16,11 +16,11 @@ final class VersionResolver /** * @var string */ - public const PACKAGE_VERSION = '8fbc6582f998a7c3330a1ca7ff731f2e8fb2476f'; + public const PACKAGE_VERSION = 'a9c6d9bd06515b5e5bbbcad3b2f7e70d3ab59125'; /** * @var string */ - public const RELEASE_DATE = '2022-05-22 18:53:13'; + public const RELEASE_DATE = '2022-05-22 18:59:41'; /** * @var string */ diff --git a/src/NodeManipulator/ClassMethodManipulator.php b/src/NodeManipulator/ClassMethodManipulator.php index 503ce1330de4..882d7b82b1e1 100644 --- a/src/NodeManipulator/ClassMethodManipulator.php +++ b/src/NodeManipulator/ClassMethodManipulator.php @@ -105,16 +105,6 @@ public function addMethodParameterIfMissing(\PhpParser\Node $node, \PHPStan\Type $classMethod->params[] = new \PhpParser\Node\Param(new \PhpParser\Node\Expr\Variable($paramName), null, new \PhpParser\Node\Name\FullyQualified($objectType->getClassName())); return $paramName; } - public function isPropertyPromotion(\PhpParser\Node\Stmt\ClassMethod $classMethod) : bool - { - foreach ($classMethod->params as $param) { - /** @var Param $param */ - if ($param->flags !== 0) { - return \true; - } - } - return \false; - } /** * @param string[] $possibleNames */ diff --git a/vendor/autoload.php b/vendor/autoload.php index 743c0c405730..61977f1c7e86 100644 --- a/vendor/autoload.php +++ b/vendor/autoload.php @@ -9,4 +9,4 @@ require_once __DIR__ . '/composer/autoload_real.php'; -return ComposerAutoloaderInitb2c7887b6fb709b9bf756eb98162016c::getLoader(); +return ComposerAutoloaderInit98a9c775c4ee7c5a6022830708dc870a::getLoader(); diff --git a/vendor/composer/autoload_real.php b/vendor/composer/autoload_real.php index 8da7559881ea..fd00b9ea1d15 100644 --- a/vendor/composer/autoload_real.php +++ b/vendor/composer/autoload_real.php @@ -2,7 +2,7 @@ // autoload_real.php @generated by Composer -class ComposerAutoloaderInitb2c7887b6fb709b9bf756eb98162016c +class ComposerAutoloaderInit98a9c775c4ee7c5a6022830708dc870a { private static $loader; @@ -22,19 +22,19 @@ public static function getLoader() return self::$loader; } - spl_autoload_register(array('ComposerAutoloaderInitb2c7887b6fb709b9bf756eb98162016c', 'loadClassLoader'), true, true); + spl_autoload_register(array('ComposerAutoloaderInit98a9c775c4ee7c5a6022830708dc870a', 'loadClassLoader'), true, true); self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__)); - spl_autoload_unregister(array('ComposerAutoloaderInitb2c7887b6fb709b9bf756eb98162016c', 'loadClassLoader')); + spl_autoload_unregister(array('ComposerAutoloaderInit98a9c775c4ee7c5a6022830708dc870a', 'loadClassLoader')); require __DIR__ . '/autoload_static.php'; - call_user_func(\Composer\Autoload\ComposerStaticInitb2c7887b6fb709b9bf756eb98162016c::getInitializer($loader)); + call_user_func(\Composer\Autoload\ComposerStaticInit98a9c775c4ee7c5a6022830708dc870a::getInitializer($loader)); $loader->setClassMapAuthoritative(true); $loader->register(true); - $includeFiles = \Composer\Autoload\ComposerStaticInitb2c7887b6fb709b9bf756eb98162016c::$files; + $includeFiles = \Composer\Autoload\ComposerStaticInit98a9c775c4ee7c5a6022830708dc870a::$files; foreach ($includeFiles as $fileIdentifier => $file) { - composerRequireb2c7887b6fb709b9bf756eb98162016c($fileIdentifier, $file); + composerRequire98a9c775c4ee7c5a6022830708dc870a($fileIdentifier, $file); } return $loader; @@ -46,7 +46,7 @@ public static function getLoader() * @param string $file * @return void */ -function composerRequireb2c7887b6fb709b9bf756eb98162016c($fileIdentifier, $file) +function composerRequire98a9c775c4ee7c5a6022830708dc870a($fileIdentifier, $file) { if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) { $GLOBALS['__composer_autoload_files'][$fileIdentifier] = true; diff --git a/vendor/composer/autoload_static.php b/vendor/composer/autoload_static.php index e2331dda3154..2155b2cc0a13 100644 --- a/vendor/composer/autoload_static.php +++ b/vendor/composer/autoload_static.php @@ -4,7 +4,7 @@ namespace Composer\Autoload; -class ComposerStaticInitb2c7887b6fb709b9bf756eb98162016c +class ComposerStaticInit98a9c775c4ee7c5a6022830708dc870a { public static $files = array ( '320cde22f66dd4f5d3fd621d3e88b98f' => __DIR__ . '/..' . '/symfony/polyfill-ctype/bootstrap.php', @@ -3909,9 +3909,9 @@ class ComposerStaticInitb2c7887b6fb709b9bf756eb98162016c public static function getInitializer(ClassLoader $loader) { return \Closure::bind(function () use ($loader) { - $loader->prefixLengthsPsr4 = ComposerStaticInitb2c7887b6fb709b9bf756eb98162016c::$prefixLengthsPsr4; - $loader->prefixDirsPsr4 = ComposerStaticInitb2c7887b6fb709b9bf756eb98162016c::$prefixDirsPsr4; - $loader->classMap = ComposerStaticInitb2c7887b6fb709b9bf756eb98162016c::$classMap; + $loader->prefixLengthsPsr4 = ComposerStaticInit98a9c775c4ee7c5a6022830708dc870a::$prefixLengthsPsr4; + $loader->prefixDirsPsr4 = ComposerStaticInit98a9c775c4ee7c5a6022830708dc870a::$prefixDirsPsr4; + $loader->classMap = ComposerStaticInit98a9c775c4ee7c5a6022830708dc870a::$classMap; }, null, ClassLoader::class); } diff --git a/vendor/scoper-autoload.php b/vendor/scoper-autoload.php index 8b999124100c..3918e1501d54 100644 --- a/vendor/scoper-autoload.php +++ b/vendor/scoper-autoload.php @@ -9,8 +9,8 @@ if (!class_exists('AutoloadIncluder', false) && !interface_exists('AutoloadIncluder', false) && !trait_exists('AutoloadIncluder', false)) { spl_autoload_call('RectorPrefix20220522\AutoloadIncluder'); } -if (!class_exists('ComposerAutoloaderInitb2c7887b6fb709b9bf756eb98162016c', false) && !interface_exists('ComposerAutoloaderInitb2c7887b6fb709b9bf756eb98162016c', false) && !trait_exists('ComposerAutoloaderInitb2c7887b6fb709b9bf756eb98162016c', false)) { - spl_autoload_call('RectorPrefix20220522\ComposerAutoloaderInitb2c7887b6fb709b9bf756eb98162016c'); +if (!class_exists('ComposerAutoloaderInit98a9c775c4ee7c5a6022830708dc870a', false) && !interface_exists('ComposerAutoloaderInit98a9c775c4ee7c5a6022830708dc870a', false) && !trait_exists('ComposerAutoloaderInit98a9c775c4ee7c5a6022830708dc870a', false)) { + spl_autoload_call('RectorPrefix20220522\ComposerAutoloaderInit98a9c775c4ee7c5a6022830708dc870a'); } 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('RectorPrefix20220522\Helmich\TypoScriptParser\Parser\AST\Statement'); @@ -59,9 +59,9 @@ function print_node() { return \RectorPrefix20220522\print_node(...func_get_args()); } } -if (!function_exists('composerRequireb2c7887b6fb709b9bf756eb98162016c')) { - function composerRequireb2c7887b6fb709b9bf756eb98162016c() { - return \RectorPrefix20220522\composerRequireb2c7887b6fb709b9bf756eb98162016c(...func_get_args()); +if (!function_exists('composerRequire98a9c775c4ee7c5a6022830708dc870a')) { + function composerRequire98a9c775c4ee7c5a6022830708dc870a() { + return \RectorPrefix20220522\composerRequire98a9c775c4ee7c5a6022830708dc870a(...func_get_args()); } } if (!function_exists('scanPath')) {