Updated Rector to commit 8e67265bbebb84e6b4dc8f3249ea191710980988

8e67265bbe [CodeQuality] Handle crash on variable variable on assign closure on OptionalParametersAfterRequiredRector (#5089)
This commit is contained in:
Tomas Votruba 2023-09-28 13:11:33 +00:00
parent 7ff3aa40b8
commit fb1a354817
6 changed files with 33 additions and 17 deletions

View File

@ -207,7 +207,7 @@ final class PHPStanNodeScopeResolver
$this->nodeScopeResolver->processNodes($stmts, $scope, $nodeCallback);
$nodeTraverser = new NodeTraverser();
$nodeTraverser->addVisitor(new WrappedNodeRestoringNodeVisitor());
$nodeTraverser->addVisitor(new ExprScopeFromStmtNodeVisitor($scope));
$nodeTraverser->addVisitor(new ExprScopeFromStmtNodeVisitor($this, $filePath, $scope));
$nodeTraverser->traverse($stmts);
return $stmts;
}

View File

@ -19,12 +19,12 @@ final class VersionResolver
* @api
* @var string
*/
public const PACKAGE_VERSION = '2f901255da37c64388cdfc9eb6d98c53ccc388b9';
public const PACKAGE_VERSION = '8e67265bbebb84e6b4dc8f3249ea191710980988';
/**
* @api
* @var string
*/
public const RELEASE_DATE = '2023-09-28 11:17:03';
public const RELEASE_DATE = '2023-09-28 20:08:06';
/**
* @var int
*/

View File

@ -5,6 +5,7 @@ namespace Rector\Core\PHPStan\NodeVisitor;
use PhpParser\Node;
use PhpParser\Node\Expr;
use PhpParser\Node\Expr\Closure;
use PhpParser\Node\Stmt;
use PhpParser\Node\Stmt\ClassLike;
use PhpParser\Node\Stmt\ClassMethod;
@ -12,12 +13,22 @@ use PhpParser\Node\Stmt\Function_;
use PhpParser\Node\Stmt\Namespace_;
use PhpParser\NodeVisitorAbstract;
use PHPStan\Analyser\MutatingScope;
use PHPStan\Analyser\Scope;
use PHPStan\Node\VirtualNode;
use Rector\Core\PhpParser\Node\CustomNode\FileWithoutNamespace;
use Rector\NodeTypeResolver\Node\AttributeKey;
use Rector\NodeTypeResolver\PHPStan\Scope\PHPStanNodeScopeResolver;
final class ExprScopeFromStmtNodeVisitor extends NodeVisitorAbstract
{
/**
* @readonly
* @var \Rector\NodeTypeResolver\PHPStan\Scope\PHPStanNodeScopeResolver
*/
private $phpStanNodeScopeResolver;
/**
* @readonly
* @var string
*/
private $filePath;
/**
* @readonly
* @var \PHPStan\Analyser\MutatingScope
@ -27,8 +38,10 @@ final class ExprScopeFromStmtNodeVisitor extends NodeVisitorAbstract
* @var \PhpParser\Node\Stmt|null
*/
private $currentStmt;
public function __construct(MutatingScope $mutatingScope)
public function __construct(PHPStanNodeScopeResolver $phpStanNodeScopeResolver, string $filePath, MutatingScope $mutatingScope)
{
$this->phpStanNodeScopeResolver = $phpStanNodeScopeResolver;
$this->filePath = $filePath;
$this->mutatingScope = $mutatingScope;
}
public function enterNode(Node $node) : ?Node
@ -47,13 +60,16 @@ final class ExprScopeFromStmtNodeVisitor extends NodeVisitorAbstract
return null;
}
$scope = $node->getAttribute(AttributeKey::SCOPE);
if ($scope instanceof Scope) {
if ($scope instanceof MutatingScope) {
return null;
}
// too deep Expr, eg: $$param = $$bar = self::decodeValue($result->getItem()->getTextContent());
$scope = $this->currentStmt instanceof Stmt ? $this->currentStmt->getAttribute(AttributeKey::SCOPE) : $this->mutatingScope;
$scope = $scope instanceof Scope ? $scope : $this->mutatingScope;
$scope = $scope instanceof MutatingScope ? $scope : $this->mutatingScope;
$node->setAttribute(AttributeKey::SCOPE, $scope);
if ($node instanceof Closure) {
$this->phpStanNodeScopeResolver->processNodes($node->stmts, $this->filePath, $scope);
}
return null;
}
}

2
vendor/autoload.php vendored
View File

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

View File

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