From ca8754469c7bd6b9b5ebf2e758cf03dd3a8302d7 Mon Sep 17 00:00:00 2001 From: Tomas Votruba Date: Sun, 11 Jun 2023 05:54:40 +0000 Subject: [PATCH] Updated Rector to commit 424b874e8cbfde95c46e1bba12ffe6931c375197 https://github.com/rectorphp/rector-src/commit/424b874e8cbfde95c46e1bba12ffe6931c375197 [NodeManipulator] Remove parent lookup on ClassMethodPropertyFetchManipulator (#4170) --- src/Application/VersionResolver.php | 4 +-- src/Kernel/RectorKernel.php | 2 +- .../ClassMethodPropertyFetchManipulator.php | 28 +++++++------------ vendor/autoload.php | 2 +- vendor/composer/autoload_real.php | 10 +++---- vendor/composer/autoload_static.php | 8 +++--- 6 files changed, 23 insertions(+), 31 deletions(-) diff --git a/src/Application/VersionResolver.php b/src/Application/VersionResolver.php index 8b20345026d..52eed4b4add 100644 --- a/src/Application/VersionResolver.php +++ b/src/Application/VersionResolver.php @@ -19,12 +19,12 @@ final class VersionResolver * @api * @var string */ - public const PACKAGE_VERSION = 'ea2ee121e0b6388fdcda0125f7dca941a44edc3a'; + public const PACKAGE_VERSION = '424b874e8cbfde95c46e1bba12ffe6931c375197'; /** * @api * @var string */ - public const RELEASE_DATE = '2023-06-11 12:42:01'; + public const RELEASE_DATE = '2023-06-11 12:50:49'; /** * @var int */ diff --git a/src/Kernel/RectorKernel.php b/src/Kernel/RectorKernel.php index 3619708b3fc..b966a1a4351 100644 --- a/src/Kernel/RectorKernel.php +++ b/src/Kernel/RectorKernel.php @@ -15,7 +15,7 @@ final class RectorKernel /** * @var string */ - private const CACHE_KEY = 'v90'; + private const CACHE_KEY = 'v91'; /** * @var \Symfony\Component\DependencyInjection\ContainerInterface|null */ diff --git a/src/NodeManipulator/ClassMethodPropertyFetchManipulator.php b/src/NodeManipulator/ClassMethodPropertyFetchManipulator.php index 087732cb3f0..0e829317a86 100644 --- a/src/NodeManipulator/ClassMethodPropertyFetchManipulator.php +++ b/src/NodeManipulator/ClassMethodPropertyFetchManipulator.php @@ -11,9 +11,9 @@ use PhpParser\Node\Expr\PropertyFetch; use PhpParser\Node\Expr\StaticCall; use PhpParser\Node\Expr\StaticPropertyFetch; use PhpParser\Node\Param; +use PhpParser\Node\Stmt\Class_; use PhpParser\Node\Stmt\ClassMethod; use PhpParser\NodeTraverser; -use Rector\Core\PhpParser\Node\BetterNodeFinder; use Rector\NodeNameResolver\NodeNameResolver; use Rector\PhpDocParser\NodeTraverser\SimpleCallableNodeTraverser; final class ClassMethodPropertyFetchManipulator @@ -28,21 +28,15 @@ final class ClassMethodPropertyFetchManipulator * @var \Rector\NodeNameResolver\NodeNameResolver */ private $nodeNameResolver; - /** - * @readonly - * @var \Rector\Core\PhpParser\Node\BetterNodeFinder - */ - private $betterNodeFinder; /** * @readonly * @var \Rector\Core\NodeManipulator\FunctionLikeManipulator */ private $functionLikeManipulator; - public function __construct(SimpleCallableNodeTraverser $simpleCallableNodeTraverser, NodeNameResolver $nodeNameResolver, BetterNodeFinder $betterNodeFinder, \Rector\Core\NodeManipulator\FunctionLikeManipulator $functionLikeManipulator) + public function __construct(SimpleCallableNodeTraverser $simpleCallableNodeTraverser, NodeNameResolver $nodeNameResolver, \Rector\Core\NodeManipulator\FunctionLikeManipulator $functionLikeManipulator) { $this->simpleCallableNodeTraverser = $simpleCallableNodeTraverser; $this->nodeNameResolver = $nodeNameResolver; - $this->betterNodeFinder = $betterNodeFinder; $this->functionLikeManipulator = $functionLikeManipulator; } /** @@ -57,7 +51,10 @@ final class ClassMethodPropertyFetchManipulator public function findParamAssignToPropertyName(ClassMethod $classMethod, string $propertyName) : ?Param { $assignedParamName = null; - $this->simpleCallableNodeTraverser->traverseNodesWithCallable((array) $classMethod->stmts, function (Node $node) use($propertyName, &$assignedParamName, $classMethod) : ?int { + $this->simpleCallableNodeTraverser->traverseNodesWithCallable((array) $classMethod->stmts, function (Node $node) use($propertyName, &$assignedParamName) : ?int { + if ($node instanceof Class_) { + return NodeTraverser::DONT_TRAVERSE_CURRENT_AND_CHILDREN; + } if (!$node instanceof Assign) { return null; } @@ -70,10 +67,6 @@ final class ClassMethodPropertyFetchManipulator if ($node->expr instanceof MethodCall || $node->expr instanceof StaticCall) { return null; } - $parentClassMethod = $this->betterNodeFinder->findParentType($node, ClassMethod::class); - if ($parentClassMethod !== $classMethod) { - return null; - } $assignedParamName = $this->nodeNameResolver->getName($node->expr); return NodeTraverser::STOP_TRAVERSAL; }); @@ -102,7 +95,10 @@ final class ClassMethodPropertyFetchManipulator { $assignExprs = []; $paramNames = $this->functionLikeManipulator->resolveParamNames($classMethod); - $this->simpleCallableNodeTraverser->traverseNodesWithCallable((array) $classMethod->stmts, function (Node $node) use($propertyName, &$assignExprs, $paramNames, $classMethod) : ?int { + $this->simpleCallableNodeTraverser->traverseNodesWithCallable((array) $classMethod->stmts, function (Node $node) use($propertyName, &$assignExprs, $paramNames) : ?int { + if ($node instanceof Class_) { + return NodeTraverser::DONT_TRAVERSE_CURRENT_AND_CHILDREN; + } if (!$node instanceof Assign) { return null; } @@ -116,10 +112,6 @@ final class ClassMethodPropertyFetchManipulator if ($this->nodeNameResolver->isNames($node->expr, $paramNames)) { return null; } - $parentClassMethod = $this->betterNodeFinder->findParentType($node, ClassMethod::class); - if ($parentClassMethod !== $classMethod) { - return null; - } $assignExprs[] = $node->expr; return null; }); diff --git a/vendor/autoload.php b/vendor/autoload.php index 6242d039315..bff88b283a5 100644 --- a/vendor/autoload.php +++ b/vendor/autoload.php @@ -22,4 +22,4 @@ if (PHP_VERSION_ID < 50600) { require_once __DIR__ . '/composer/autoload_real.php'; -return ComposerAutoloaderInit2a46dd31cd0649b8ab5689ec3d5eed81::getLoader(); +return ComposerAutoloaderInit2378f77656410cec75dca53cf234ebb4::getLoader(); diff --git a/vendor/composer/autoload_real.php b/vendor/composer/autoload_real.php index 566bf53513d..28cdb4ff385 100644 --- a/vendor/composer/autoload_real.php +++ b/vendor/composer/autoload_real.php @@ -2,7 +2,7 @@ // autoload_real.php @generated by Composer -class ComposerAutoloaderInit2a46dd31cd0649b8ab5689ec3d5eed81 +class ComposerAutoloaderInit2378f77656410cec75dca53cf234ebb4 { private static $loader; @@ -22,17 +22,17 @@ class ComposerAutoloaderInit2a46dd31cd0649b8ab5689ec3d5eed81 return self::$loader; } - spl_autoload_register(array('ComposerAutoloaderInit2a46dd31cd0649b8ab5689ec3d5eed81', 'loadClassLoader'), true, true); + spl_autoload_register(array('ComposerAutoloaderInit2378f77656410cec75dca53cf234ebb4', 'loadClassLoader'), true, true); self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__)); - spl_autoload_unregister(array('ComposerAutoloaderInit2a46dd31cd0649b8ab5689ec3d5eed81', 'loadClassLoader')); + spl_autoload_unregister(array('ComposerAutoloaderInit2378f77656410cec75dca53cf234ebb4', 'loadClassLoader')); require __DIR__ . '/autoload_static.php'; - call_user_func(\Composer\Autoload\ComposerStaticInit2a46dd31cd0649b8ab5689ec3d5eed81::getInitializer($loader)); + call_user_func(\Composer\Autoload\ComposerStaticInit2378f77656410cec75dca53cf234ebb4::getInitializer($loader)); $loader->setClassMapAuthoritative(true); $loader->register(true); - $filesToLoad = \Composer\Autoload\ComposerStaticInit2a46dd31cd0649b8ab5689ec3d5eed81::$files; + $filesToLoad = \Composer\Autoload\ComposerStaticInit2378f77656410cec75dca53cf234ebb4::$files; $requireFile = \Closure::bind(static function ($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 d069b8cfdea..1942e642872 100644 --- a/vendor/composer/autoload_static.php +++ b/vendor/composer/autoload_static.php @@ -4,7 +4,7 @@ namespace Composer\Autoload; -class ComposerStaticInit2a46dd31cd0649b8ab5689ec3d5eed81 +class ComposerStaticInit2378f77656410cec75dca53cf234ebb4 { public static $files = array ( 'ad155f8f1cf0d418fe49e248db8c661b' => __DIR__ . '/..' . '/react/promise/src/functions_include.php', @@ -3127,9 +3127,9 @@ class ComposerStaticInit2a46dd31cd0649b8ab5689ec3d5eed81 public static function getInitializer(ClassLoader $loader) { return \Closure::bind(function () use ($loader) { - $loader->prefixLengthsPsr4 = ComposerStaticInit2a46dd31cd0649b8ab5689ec3d5eed81::$prefixLengthsPsr4; - $loader->prefixDirsPsr4 = ComposerStaticInit2a46dd31cd0649b8ab5689ec3d5eed81::$prefixDirsPsr4; - $loader->classMap = ComposerStaticInit2a46dd31cd0649b8ab5689ec3d5eed81::$classMap; + $loader->prefixLengthsPsr4 = ComposerStaticInit2378f77656410cec75dca53cf234ebb4::$prefixLengthsPsr4; + $loader->prefixDirsPsr4 = ComposerStaticInit2378f77656410cec75dca53cf234ebb4::$prefixDirsPsr4; + $loader->classMap = ComposerStaticInit2378f77656410cec75dca53cf234ebb4::$classMap; }, null, ClassLoader::class); }