From e0644186883856ab6ba39ecf3d9bdf3ebd85fa35 Mon Sep 17 00:00:00 2001 From: Tomas Votruba Date: Mon, 19 Jun 2023 16:09:00 +0000 Subject: [PATCH] Updated Rector to commit 5e1601086d921c549fc28f69ac32ec127c2c47b0 https://github.com/rectorphp/rector-src/commit/5e1601086d921c549fc28f69ac32ec127c2c47b0 [Performance] Use direct BetterNodeFinder::find() on LocalMethodCallFinder::match() (#4287) --- src/Application/VersionResolver.php | 4 +-- .../NodeFinder/LocalMethodCallFinder.php | 25 +++++++++---------- vendor/autoload.php | 2 +- vendor/composer/autoload_real.php | 10 ++++---- vendor/composer/autoload_static.php | 8 +++--- 5 files changed, 24 insertions(+), 25 deletions(-) diff --git a/src/Application/VersionResolver.php b/src/Application/VersionResolver.php index ab4ed2b6ec5..e8338fa776b 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 = '1afeeb91592de9e2738f179c5d7ad82533bf5042'; + public const PACKAGE_VERSION = '5e1601086d921c549fc28f69ac32ec127c2c47b0'; /** * @api * @var string */ - public const RELEASE_DATE = '2023-06-19 15:53:55'; + public const RELEASE_DATE = '2023-06-19 23:05:05'; /** * @var int */ diff --git a/src/PhpParser/NodeFinder/LocalMethodCallFinder.php b/src/PhpParser/NodeFinder/LocalMethodCallFinder.php index 8859146e2c7..5ecc02972c6 100644 --- a/src/PhpParser/NodeFinder/LocalMethodCallFinder.php +++ b/src/PhpParser/NodeFinder/LocalMethodCallFinder.php @@ -3,6 +3,7 @@ declare (strict_types=1); namespace Rector\Core\PhpParser\NodeFinder; +use PhpParser\Node; use PhpParser\Node\Expr\MethodCall; use PhpParser\Node\Stmt\Class_; use PhpParser\Node\Stmt\ClassMethod; @@ -42,23 +43,21 @@ final class LocalMethodCallFinder if (!\is_string($className)) { return []; } - /** @var MethodCall[] $methodCalls */ - $methodCalls = $this->betterNodeFinder->findInstanceOf($class->getMethods(), MethodCall::class); $classMethodName = $this->nodeNameResolver->getName($classMethod); - $matchingMethodCalls = []; - foreach ($methodCalls as $methodCall) { - if (!$this->nodeNameResolver->isName($methodCall->name, $classMethodName)) { - continue; + /** @var MethodCall[] $matchingMethodCalls */ + $matchingMethodCalls = $this->betterNodeFinder->find($class->getMethods(), function (Node $subNode) use($className, $classMethodName) : bool { + if (!$subNode instanceof MethodCall) { + return \false; } - $callerType = $this->nodeTypeResolver->getType($methodCall->var); + if (!$this->nodeNameResolver->isName($subNode->name, $classMethodName)) { + return \false; + } + $callerType = $this->nodeTypeResolver->getType($subNode->var); if (!$callerType instanceof TypeWithClassName) { - continue; + return \false; } - if ($callerType->getClassName() !== $className) { - continue; - } - $matchingMethodCalls[] = $methodCall; - } + return $callerType->getClassName() === $className; + }); return $matchingMethodCalls; } } diff --git a/vendor/autoload.php b/vendor/autoload.php index 95f9feb32c3..51a22625804 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 ComposerAutoloaderInitac162127ef3327a5106e16a48bf29b60::getLoader(); +return ComposerAutoloaderInitf3544180700689daaf43dc275bc0eb53::getLoader(); diff --git a/vendor/composer/autoload_real.php b/vendor/composer/autoload_real.php index 66d3e2dccc6..d28a7148417 100644 --- a/vendor/composer/autoload_real.php +++ b/vendor/composer/autoload_real.php @@ -2,7 +2,7 @@ // autoload_real.php @generated by Composer -class ComposerAutoloaderInitac162127ef3327a5106e16a48bf29b60 +class ComposerAutoloaderInitf3544180700689daaf43dc275bc0eb53 { private static $loader; @@ -22,17 +22,17 @@ class ComposerAutoloaderInitac162127ef3327a5106e16a48bf29b60 return self::$loader; } - spl_autoload_register(array('ComposerAutoloaderInitac162127ef3327a5106e16a48bf29b60', 'loadClassLoader'), true, true); + spl_autoload_register(array('ComposerAutoloaderInitf3544180700689daaf43dc275bc0eb53', 'loadClassLoader'), true, true); self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__)); - spl_autoload_unregister(array('ComposerAutoloaderInitac162127ef3327a5106e16a48bf29b60', 'loadClassLoader')); + spl_autoload_unregister(array('ComposerAutoloaderInitf3544180700689daaf43dc275bc0eb53', 'loadClassLoader')); require __DIR__ . '/autoload_static.php'; - call_user_func(\Composer\Autoload\ComposerStaticInitac162127ef3327a5106e16a48bf29b60::getInitializer($loader)); + call_user_func(\Composer\Autoload\ComposerStaticInitf3544180700689daaf43dc275bc0eb53::getInitializer($loader)); $loader->setClassMapAuthoritative(true); $loader->register(true); - $filesToLoad = \Composer\Autoload\ComposerStaticInitac162127ef3327a5106e16a48bf29b60::$files; + $filesToLoad = \Composer\Autoload\ComposerStaticInitf3544180700689daaf43dc275bc0eb53::$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 6249c052ff8..214523f48f1 100644 --- a/vendor/composer/autoload_static.php +++ b/vendor/composer/autoload_static.php @@ -4,7 +4,7 @@ namespace Composer\Autoload; -class ComposerStaticInitac162127ef3327a5106e16a48bf29b60 +class ComposerStaticInitf3544180700689daaf43dc275bc0eb53 { public static $files = array ( 'ad155f8f1cf0d418fe49e248db8c661b' => __DIR__ . '/..' . '/react/promise/src/functions_include.php', @@ -3095,9 +3095,9 @@ class ComposerStaticInitac162127ef3327a5106e16a48bf29b60 public static function getInitializer(ClassLoader $loader) { return \Closure::bind(function () use ($loader) { - $loader->prefixLengthsPsr4 = ComposerStaticInitac162127ef3327a5106e16a48bf29b60::$prefixLengthsPsr4; - $loader->prefixDirsPsr4 = ComposerStaticInitac162127ef3327a5106e16a48bf29b60::$prefixDirsPsr4; - $loader->classMap = ComposerStaticInitac162127ef3327a5106e16a48bf29b60::$classMap; + $loader->prefixLengthsPsr4 = ComposerStaticInitf3544180700689daaf43dc275bc0eb53::$prefixLengthsPsr4; + $loader->prefixDirsPsr4 = ComposerStaticInitf3544180700689daaf43dc275bc0eb53::$prefixDirsPsr4; + $loader->classMap = ComposerStaticInitf3544180700689daaf43dc275bc0eb53::$classMap; }, null, ClassLoader::class); }