mirror of
https://github.com/rectorphp/rector.git
synced 2025-01-18 22:08:00 +01:00
Updated Rector to commit 6f1b98ef3bf17f9b0d8df592e8605479c628b2c8
6f1b98ef3b
[NodeCollector] Reduce parent lookup on ArrayCallableMethodMatcher on detect array in Attribute (#4275)
This commit is contained in:
parent
ad1bdeeb0f
commit
fe68d59192
@ -4,7 +4,6 @@ declare (strict_types=1);
|
||||
namespace Rector\NodeCollector\NodeAnalyzer;
|
||||
|
||||
use PhpParser\Node\Arg;
|
||||
use PhpParser\Node\Attribute;
|
||||
use PhpParser\Node\Expr;
|
||||
use PhpParser\Node\Expr\Array_;
|
||||
use PhpParser\Node\Expr\ArrayItem;
|
||||
@ -88,8 +87,7 @@ final class ArrayCallableMethodMatcher
|
||||
if (!$callerType instanceof TypeWithClassName) {
|
||||
return null;
|
||||
}
|
||||
$isInAttribute = (bool) $this->betterNodeFinder->findParentType($array, Attribute::class);
|
||||
if ($isInAttribute) {
|
||||
if ($array->getAttribute(AttributeKey::IS_ARRAY_IN_ATTRIBUTE) === \true) {
|
||||
return null;
|
||||
}
|
||||
$values = $this->valueResolver->getValue($array);
|
||||
|
@ -192,4 +192,8 @@ final class AttributeKey
|
||||
* @var string
|
||||
*/
|
||||
public const IS_UNSET_VAR = 'is_unset_var';
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public const IS_ARRAY_IN_ATTRIBUTE = 'is_array_in_attribute';
|
||||
}
|
||||
|
@ -4,6 +4,8 @@ declare (strict_types=1);
|
||||
namespace Rector\NodeTypeResolver\PHPStan\Scope\NodeVisitor;
|
||||
|
||||
use PhpParser\Node;
|
||||
use PhpParser\Node\Attribute;
|
||||
use PhpParser\Node\Expr\Array_;
|
||||
use PhpParser\Node\Expr\ArrowFunction;
|
||||
use PhpParser\Node\FunctionLike;
|
||||
use PhpParser\Node\Stmt\Break_;
|
||||
@ -33,6 +35,29 @@ final class ContextNodeVisitor extends NodeVisitorAbstract implements ScopeResol
|
||||
public function enterNode(Node $node) : ?Node
|
||||
{
|
||||
if ($node instanceof For_ || $node instanceof Foreach_ || $node instanceof While_ || $node instanceof Do_) {
|
||||
$this->processContextInLoop($node);
|
||||
return null;
|
||||
}
|
||||
if ($node instanceof Unset_) {
|
||||
foreach ($node->vars as $var) {
|
||||
$var->setAttribute(AttributeKey::IS_UNSET_VAR, \true);
|
||||
}
|
||||
}
|
||||
if ($node instanceof Attribute) {
|
||||
$this->simpleCallableNodeTraverser->traverseNodesWithCallable($node->args, static function (Node $subNode) {
|
||||
if ($subNode instanceof Array_) {
|
||||
$subNode->setAttribute(AttributeKey::IS_ARRAY_IN_ATTRIBUTE, \true);
|
||||
}
|
||||
return null;
|
||||
});
|
||||
}
|
||||
return null;
|
||||
}
|
||||
/**
|
||||
* @param \PhpParser\Node\Stmt\For_|\PhpParser\Node\Stmt\Foreach_|\PhpParser\Node\Stmt\While_|\PhpParser\Node\Stmt\Do_ $node
|
||||
*/
|
||||
private function processContextInLoop($node) : void
|
||||
{
|
||||
$this->simpleCallableNodeTraverser->traverseNodesWithCallable($node->stmts, static function (Node $subNode) : ?int {
|
||||
if ($subNode instanceof Class_ || $subNode instanceof FunctionLike && !$subNode instanceof ArrowFunction) {
|
||||
return NodeTraverser::DONT_TRAVERSE_CURRENT_AND_CHILDREN;
|
||||
@ -42,13 +67,5 @@ final class ContextNodeVisitor extends NodeVisitorAbstract implements ScopeResol
|
||||
}
|
||||
return null;
|
||||
});
|
||||
return null;
|
||||
}
|
||||
if ($node instanceof Unset_) {
|
||||
foreach ($node->vars as $var) {
|
||||
$var->setAttribute(AttributeKey::IS_UNSET_VAR, \true);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@ -19,12 +19,12 @@ final class VersionResolver
|
||||
* @api
|
||||
* @var string
|
||||
*/
|
||||
public const PACKAGE_VERSION = '18436f1f44262a6dcc0dcb6d5bb88eb439a53045';
|
||||
public const PACKAGE_VERSION = '6f1b98ef3bf17f9b0d8df592e8605479c628b2c8';
|
||||
/**
|
||||
* @api
|
||||
* @var string
|
||||
*/
|
||||
public const RELEASE_DATE = '2023-06-18 17:45:05';
|
||||
public const RELEASE_DATE = '2023-06-18 20:11:18';
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
|
2
vendor/autoload.php
vendored
2
vendor/autoload.php
vendored
@ -22,4 +22,4 @@ if (PHP_VERSION_ID < 50600) {
|
||||
|
||||
require_once __DIR__ . '/composer/autoload_real.php';
|
||||
|
||||
return ComposerAutoloaderInitbb2ba2a619778f3c7e218eb9b59b79e3::getLoader();
|
||||
return ComposerAutoloaderInitd8580d9b018097d03475b33f8ce21ff9::getLoader();
|
||||
|
10
vendor/composer/autoload_real.php
vendored
10
vendor/composer/autoload_real.php
vendored
@ -2,7 +2,7 @@
|
||||
|
||||
// autoload_real.php @generated by Composer
|
||||
|
||||
class ComposerAutoloaderInitbb2ba2a619778f3c7e218eb9b59b79e3
|
||||
class ComposerAutoloaderInitd8580d9b018097d03475b33f8ce21ff9
|
||||
{
|
||||
private static $loader;
|
||||
|
||||
@ -22,17 +22,17 @@ class ComposerAutoloaderInitbb2ba2a619778f3c7e218eb9b59b79e3
|
||||
return self::$loader;
|
||||
}
|
||||
|
||||
spl_autoload_register(array('ComposerAutoloaderInitbb2ba2a619778f3c7e218eb9b59b79e3', 'loadClassLoader'), true, true);
|
||||
spl_autoload_register(array('ComposerAutoloaderInitd8580d9b018097d03475b33f8ce21ff9', 'loadClassLoader'), true, true);
|
||||
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__));
|
||||
spl_autoload_unregister(array('ComposerAutoloaderInitbb2ba2a619778f3c7e218eb9b59b79e3', 'loadClassLoader'));
|
||||
spl_autoload_unregister(array('ComposerAutoloaderInitd8580d9b018097d03475b33f8ce21ff9', 'loadClassLoader'));
|
||||
|
||||
require __DIR__ . '/autoload_static.php';
|
||||
call_user_func(\Composer\Autoload\ComposerStaticInitbb2ba2a619778f3c7e218eb9b59b79e3::getInitializer($loader));
|
||||
call_user_func(\Composer\Autoload\ComposerStaticInitd8580d9b018097d03475b33f8ce21ff9::getInitializer($loader));
|
||||
|
||||
$loader->setClassMapAuthoritative(true);
|
||||
$loader->register(true);
|
||||
|
||||
$filesToLoad = \Composer\Autoload\ComposerStaticInitbb2ba2a619778f3c7e218eb9b59b79e3::$files;
|
||||
$filesToLoad = \Composer\Autoload\ComposerStaticInitd8580d9b018097d03475b33f8ce21ff9::$files;
|
||||
$requireFile = \Closure::bind(static function ($fileIdentifier, $file) {
|
||||
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
|
||||
$GLOBALS['__composer_autoload_files'][$fileIdentifier] = true;
|
||||
|
8
vendor/composer/autoload_static.php
vendored
8
vendor/composer/autoload_static.php
vendored
@ -4,7 +4,7 @@
|
||||
|
||||
namespace Composer\Autoload;
|
||||
|
||||
class ComposerStaticInitbb2ba2a619778f3c7e218eb9b59b79e3
|
||||
class ComposerStaticInitd8580d9b018097d03475b33f8ce21ff9
|
||||
{
|
||||
public static $files = array (
|
||||
'ad155f8f1cf0d418fe49e248db8c661b' => __DIR__ . '/..' . '/react/promise/src/functions_include.php',
|
||||
@ -3095,9 +3095,9 @@ class ComposerStaticInitbb2ba2a619778f3c7e218eb9b59b79e3
|
||||
public static function getInitializer(ClassLoader $loader)
|
||||
{
|
||||
return \Closure::bind(function () use ($loader) {
|
||||
$loader->prefixLengthsPsr4 = ComposerStaticInitbb2ba2a619778f3c7e218eb9b59b79e3::$prefixLengthsPsr4;
|
||||
$loader->prefixDirsPsr4 = ComposerStaticInitbb2ba2a619778f3c7e218eb9b59b79e3::$prefixDirsPsr4;
|
||||
$loader->classMap = ComposerStaticInitbb2ba2a619778f3c7e218eb9b59b79e3::$classMap;
|
||||
$loader->prefixLengthsPsr4 = ComposerStaticInitd8580d9b018097d03475b33f8ce21ff9::$prefixLengthsPsr4;
|
||||
$loader->prefixDirsPsr4 = ComposerStaticInitd8580d9b018097d03475b33f8ce21ff9::$prefixDirsPsr4;
|
||||
$loader->classMap = ComposerStaticInitd8580d9b018097d03475b33f8ce21ff9::$classMap;
|
||||
|
||||
}, null, ClassLoader::class);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user