Updated Rector to commit 1afeeb91592de9e2738f179c5d7ad82533bf5042

1afeeb9159 [Performance] Use SimpleCallableNodeTraverser instead of find instanceof then filter in PropertyFetchFinder::findLocalPropertyArrayDimFetchesAssignsByName() (#4286)
This commit is contained in:
Tomas Votruba 2023-06-19 15:58:11 +00:00
parent 7312de58c0
commit 7c4692b3bb
5 changed files with 32 additions and 22 deletions

View File

@ -19,12 +19,12 @@ final class VersionResolver
* @api
* @var string
*/
public const PACKAGE_VERSION = '6bbeaa2ac32afb454605e7cb14a935fce8019658';
public const PACKAGE_VERSION = '1afeeb91592de9e2738f179c5d7ad82533bf5042';
/**
* @api
* @var string
*/
public const RELEASE_DATE = '2023-06-19 22:42:59';
public const RELEASE_DATE = '2023-06-19 15:53:55';
/**
* @var int
*/

View File

@ -22,6 +22,7 @@ use Rector\Core\PhpParser\Node\BetterNodeFinder;
use Rector\Core\Reflection\ReflectionResolver;
use Rector\NodeNameResolver\NodeNameResolver;
use Rector\NodeTypeResolver\NodeTypeResolver;
use Rector\PhpDocParser\NodeTraverser\SimpleCallableNodeTraverser;
final class PropertyFetchFinder
{
/**
@ -54,7 +55,12 @@ final class PropertyFetchFinder
* @var \Rector\Core\NodeAnalyzer\PropertyFetchAnalyzer
*/
private $propertyFetchAnalyzer;
public function __construct(BetterNodeFinder $betterNodeFinder, NodeNameResolver $nodeNameResolver, ReflectionResolver $reflectionResolver, AstResolver $astResolver, NodeTypeResolver $nodeTypeResolver, PropertyFetchAnalyzer $propertyFetchAnalyzer)
/**
* @readonly
* @var \Rector\PhpDocParser\NodeTraverser\SimpleCallableNodeTraverser
*/
private $simpleCallableNodeTraverser;
public function __construct(BetterNodeFinder $betterNodeFinder, NodeNameResolver $nodeNameResolver, ReflectionResolver $reflectionResolver, AstResolver $astResolver, NodeTypeResolver $nodeTypeResolver, PropertyFetchAnalyzer $propertyFetchAnalyzer, SimpleCallableNodeTraverser $simpleCallableNodeTraverser)
{
$this->betterNodeFinder = $betterNodeFinder;
$this->nodeNameResolver = $nodeNameResolver;
@ -62,6 +68,7 @@ final class PropertyFetchFinder
$this->astResolver = $astResolver;
$this->nodeTypeResolver = $nodeTypeResolver;
$this->propertyFetchAnalyzer = $propertyFetchAnalyzer;
$this->simpleCallableNodeTraverser = $simpleCallableNodeTraverser;
}
/**
* @return array<PropertyFetch|StaticPropertyFetch>
@ -103,22 +110,25 @@ final class PropertyFetchFinder
public function findLocalPropertyArrayDimFetchesAssignsByName(Class_ $class, Property $property) : array
{
$propertyName = $this->nodeNameResolver->getName($property);
/** @var Assign[] $assigns */
$assigns = $this->betterNodeFinder->findInstanceOf($class, Assign::class);
/** @var ArrayDimFetch[] $propertyArrayDimFetches */
$propertyArrayDimFetches = [];
foreach ($assigns as $assign) {
if (!$assign->var instanceof ArrayDimFetch) {
continue;
$this->simpleCallableNodeTraverser->traverseNodesWithCallable($class->getMethods(), function (Node $subNode) use(&$propertyArrayDimFetches, $propertyName) {
if (!$subNode instanceof Assign) {
return null;
}
$dimFetchVar = $assign->var;
if (!$subNode->var instanceof ArrayDimFetch) {
return null;
}
$dimFetchVar = $subNode->var;
if (!$dimFetchVar->var instanceof PropertyFetch && !$dimFetchVar->var instanceof StaticPropertyFetch) {
continue;
return null;
}
if (!$this->propertyFetchAnalyzer->isLocalPropertyFetchName($dimFetchVar->var, $propertyName)) {
continue;
return null;
}
$propertyArrayDimFetches[] = $dimFetchVar;
}
return null;
});
return $propertyArrayDimFetches;
}
public function isLocalPropertyFetchByName(Expr $expr, string $propertyName) : bool

2
vendor/autoload.php vendored
View File

@ -22,4 +22,4 @@ if (PHP_VERSION_ID < 50600) {
require_once __DIR__ . '/composer/autoload_real.php';
return ComposerAutoloaderInit5e857c576186b03416131e11f5136782::getLoader();
return ComposerAutoloaderInitac162127ef3327a5106e16a48bf29b60::getLoader();

View File

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