mirror of
https://github.com/rectorphp/rector.git
synced 2025-04-11 11:02:38 +02:00
Updated Rector to commit 55bde86033d704228a71c83b6b4d597d8bc6d350
55bde86033
[Performance] Reduce possible re-create Scope on ExprScopeFromStmtNodeVisitor (#4853)
This commit is contained in:
parent
f5e2367b07
commit
e44653703c
packages/NodeTypeResolver/PHPStan/Scope
src
vendor
@ -207,7 +207,7 @@ final class PHPStanNodeScopeResolver
|
||||
$this->nodeScopeResolver->processNodes($stmts, $scope, $nodeCallback);
|
||||
$nodeTraverser = new NodeTraverser();
|
||||
$nodeTraverser->addVisitor(new WrappedNodeRestoringNodeVisitor());
|
||||
$nodeTraverser->addVisitor(new ExprScopeFromStmtNodeVisitor($this->scopeFactory, $filePath));
|
||||
$nodeTraverser->addVisitor(new ExprScopeFromStmtNodeVisitor($scope));
|
||||
$nodeTraverser->traverse($stmts);
|
||||
return $stmts;
|
||||
}
|
||||
|
@ -19,12 +19,12 @@ final class VersionResolver
|
||||
* @api
|
||||
* @var string
|
||||
*/
|
||||
public const PACKAGE_VERSION = '20133824b6589f2259982d75d052cf7be3be8182';
|
||||
public const PACKAGE_VERSION = '55bde86033d704228a71c83b6b4d597d8bc6d350';
|
||||
/**
|
||||
* @api
|
||||
* @var string
|
||||
*/
|
||||
public const RELEASE_DATE = '2023-08-25 23:01:40';
|
||||
public const RELEASE_DATE = '2023-08-25 23:51:22';
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
|
@ -8,27 +8,23 @@ use PhpParser\Node\Expr;
|
||||
use PhpParser\Node\Stmt;
|
||||
use PhpParser\NodeVisitorAbstract;
|
||||
use PHPStan\Analyser\Scope;
|
||||
use PHPStan\Node\VirtualNode;
|
||||
use Rector\NodeTypeResolver\Node\AttributeKey;
|
||||
use Rector\NodeTypeResolver\PHPStan\Scope\ScopeFactory;
|
||||
use PHPStan\Analyser\MutatingScope;
|
||||
final class ExprScopeFromStmtNodeVisitor extends NodeVisitorAbstract
|
||||
{
|
||||
/**
|
||||
* @readonly
|
||||
* @var \Rector\NodeTypeResolver\PHPStan\Scope\ScopeFactory
|
||||
* @var \PHPStan\Analyser\MutatingScope
|
||||
*/
|
||||
private $scopeFactory;
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $filePath;
|
||||
private $mutatingScope;
|
||||
/**
|
||||
* @var \PhpParser\Node\Stmt|null
|
||||
*/
|
||||
private $currentStmt;
|
||||
public function __construct(ScopeFactory $scopeFactory, string $filePath)
|
||||
public function __construct(MutatingScope $mutatingScope)
|
||||
{
|
||||
$this->scopeFactory = $scopeFactory;
|
||||
$this->filePath = $filePath;
|
||||
$this->mutatingScope = $mutatingScope;
|
||||
}
|
||||
public function enterNode(Node $node) : ?Node
|
||||
{
|
||||
@ -36,6 +32,9 @@ final class ExprScopeFromStmtNodeVisitor extends NodeVisitorAbstract
|
||||
$this->currentStmt = $node;
|
||||
return null;
|
||||
}
|
||||
if ($node instanceof VirtualNode) {
|
||||
return null;
|
||||
}
|
||||
if (!$node instanceof Expr || $node->getAttribute(AttributeKey::EXPRESSION_DEPTH) < 2) {
|
||||
return null;
|
||||
}
|
||||
@ -44,9 +43,8 @@ final class ExprScopeFromStmtNodeVisitor extends NodeVisitorAbstract
|
||||
return null;
|
||||
}
|
||||
// too deep Expr, eg: $$param = $$bar = self::decodeValue($result->getItem()->getTextContent());
|
||||
$filePath = $this->filePath;
|
||||
$scope = $this->currentStmt instanceof Stmt ? $this->currentStmt->getAttribute(AttributeKey::SCOPE) : $this->scopeFactory->createFromFile($filePath);
|
||||
$scope = $scope instanceof Scope ? $scope : $this->scopeFactory->createFromFile($filePath);
|
||||
$scope = $this->currentStmt instanceof Stmt ? $this->currentStmt->getAttribute(AttributeKey::SCOPE) : $this->mutatingScope;
|
||||
$scope = $scope instanceof Scope ? $scope : $this->mutatingScope;
|
||||
$node->setAttribute(AttributeKey::SCOPE, $scope);
|
||||
return null;
|
||||
}
|
||||
|
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 ComposerAutoloaderInit377e8fa8e207370e760218f4e7d0df01::getLoader();
|
||||
return ComposerAutoloaderInit0e6d6f04b55b1af6a8b9e11c9846481e::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 ComposerAutoloaderInit377e8fa8e207370e760218f4e7d0df01
|
||||
class ComposerAutoloaderInit0e6d6f04b55b1af6a8b9e11c9846481e
|
||||
{
|
||||
private static $loader;
|
||||
|
||||
@ -22,17 +22,17 @@ class ComposerAutoloaderInit377e8fa8e207370e760218f4e7d0df01
|
||||
return self::$loader;
|
||||
}
|
||||
|
||||
spl_autoload_register(array('ComposerAutoloaderInit377e8fa8e207370e760218f4e7d0df01', 'loadClassLoader'), true, true);
|
||||
spl_autoload_register(array('ComposerAutoloaderInit0e6d6f04b55b1af6a8b9e11c9846481e', 'loadClassLoader'), true, true);
|
||||
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__));
|
||||
spl_autoload_unregister(array('ComposerAutoloaderInit377e8fa8e207370e760218f4e7d0df01', 'loadClassLoader'));
|
||||
spl_autoload_unregister(array('ComposerAutoloaderInit0e6d6f04b55b1af6a8b9e11c9846481e', 'loadClassLoader'));
|
||||
|
||||
require __DIR__ . '/autoload_static.php';
|
||||
call_user_func(\Composer\Autoload\ComposerStaticInit377e8fa8e207370e760218f4e7d0df01::getInitializer($loader));
|
||||
call_user_func(\Composer\Autoload\ComposerStaticInit0e6d6f04b55b1af6a8b9e11c9846481e::getInitializer($loader));
|
||||
|
||||
$loader->setClassMapAuthoritative(true);
|
||||
$loader->register(true);
|
||||
|
||||
$filesToLoad = \Composer\Autoload\ComposerStaticInit377e8fa8e207370e760218f4e7d0df01::$files;
|
||||
$filesToLoad = \Composer\Autoload\ComposerStaticInit0e6d6f04b55b1af6a8b9e11c9846481e::$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 ComposerStaticInit377e8fa8e207370e760218f4e7d0df01
|
||||
class ComposerStaticInit0e6d6f04b55b1af6a8b9e11c9846481e
|
||||
{
|
||||
public static $files = array (
|
||||
'ad155f8f1cf0d418fe49e248db8c661b' => __DIR__ . '/..' . '/react/promise/src/functions_include.php',
|
||||
@ -2608,9 +2608,9 @@ class ComposerStaticInit377e8fa8e207370e760218f4e7d0df01
|
||||
public static function getInitializer(ClassLoader $loader)
|
||||
{
|
||||
return \Closure::bind(function () use ($loader) {
|
||||
$loader->prefixLengthsPsr4 = ComposerStaticInit377e8fa8e207370e760218f4e7d0df01::$prefixLengthsPsr4;
|
||||
$loader->prefixDirsPsr4 = ComposerStaticInit377e8fa8e207370e760218f4e7d0df01::$prefixDirsPsr4;
|
||||
$loader->classMap = ComposerStaticInit377e8fa8e207370e760218f4e7d0df01::$classMap;
|
||||
$loader->prefixLengthsPsr4 = ComposerStaticInit0e6d6f04b55b1af6a8b9e11c9846481e::$prefixLengthsPsr4;
|
||||
$loader->prefixDirsPsr4 = ComposerStaticInit0e6d6f04b55b1af6a8b9e11c9846481e::$prefixDirsPsr4;
|
||||
$loader->classMap = ComposerStaticInit0e6d6f04b55b1af6a8b9e11c9846481e::$classMap;
|
||||
|
||||
}, null, ClassLoader::class);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user