Updated Rector to commit 4140e7807611cb29cfcdd768e86a9203b0c69b9b

4140e78076 [Core] Handle no scope crash on foreach value with array item variable (#3068)
This commit is contained in:
Tomas Votruba 2022-11-16 14:19:15 +00:00
parent 18b5311e05
commit 18779fffd6
5 changed files with 29 additions and 14 deletions

View File

@ -6,6 +6,7 @@ namespace Rector\NodeTypeResolver\PHPStan\Scope;
use PhpParser\Node;
use PhpParser\Node\Arg;
use PhpParser\Node\Expr;
use PhpParser\Node\Expr\Array_;
use PhpParser\Node\Expr\ArrayItem;
use PhpParser\Node\Expr\Assign;
use PhpParser\Node\Expr\AssignOp;
@ -162,6 +163,12 @@ final class PHPStanNodeScopeResolver
if ($node instanceof Foreach_) {
// decorate value as well
$node->valueVar->setAttribute(AttributeKey::SCOPE, $mutatingScope);
if ($node->valueVar instanceof Array_) {
$this->processArray($node->valueVar, $mutatingScope);
}
}
if ($node instanceof Array_) {
$this->processArray($node, $mutatingScope);
}
if ($node instanceof Property) {
$this->processProperty($node, $mutatingScope);
@ -211,6 +218,14 @@ final class PHPStanNodeScopeResolver
};
return $this->processNodesWithDependentFiles($filePath, $stmts, $scope, $nodeCallback);
}
private function processArray(Array_ $array, MutatingScope $mutatingScope) : void
{
foreach ($array->items as $arrayItem) {
if ($arrayItem instanceof ArrayItem) {
$arrayItem->setAttribute(AttributeKey::SCOPE, $mutatingScope);
}
}
}
private function processArrayItem(ArrayItem $arrayItem, MutatingScope $mutatingScope) : void
{
if ($arrayItem->key instanceof Expr) {

View File

@ -17,12 +17,12 @@ final class VersionResolver
* @api
* @var string
*/
public const PACKAGE_VERSION = 'fa9a953fc8df6d31c24b0415b177580f7edd4100';
public const PACKAGE_VERSION = '4140e7807611cb29cfcdd768e86a9203b0c69b9b';
/**
* @api
* @var string
*/
public const RELEASE_DATE = '2022-11-15 21:25:56';
public const RELEASE_DATE = '2022-11-16 21:13:31';
/**
* @var int
*/

2
vendor/autoload.php vendored
View File

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

View File

@ -2,7 +2,7 @@
// autoload_real.php @generated by Composer
class ComposerAutoloaderInit856beaf073331b6a66817a28e08a58fc
class ComposerAutoloaderInita71e3fc1f9700a5d679aa07e296cbdbd
{
private static $loader;
@ -22,19 +22,19 @@ class ComposerAutoloaderInit856beaf073331b6a66817a28e08a58fc
return self::$loader;
}
spl_autoload_register(array('ComposerAutoloaderInit856beaf073331b6a66817a28e08a58fc', 'loadClassLoader'), true, true);
spl_autoload_register(array('ComposerAutoloaderInita71e3fc1f9700a5d679aa07e296cbdbd', 'loadClassLoader'), true, true);
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__));
spl_autoload_unregister(array('ComposerAutoloaderInit856beaf073331b6a66817a28e08a58fc', 'loadClassLoader'));
spl_autoload_unregister(array('ComposerAutoloaderInita71e3fc1f9700a5d679aa07e296cbdbd', 'loadClassLoader'));
require __DIR__ . '/autoload_static.php';
call_user_func(\Composer\Autoload\ComposerStaticInit856beaf073331b6a66817a28e08a58fc::getInitializer($loader));
call_user_func(\Composer\Autoload\ComposerStaticInita71e3fc1f9700a5d679aa07e296cbdbd::getInitializer($loader));
$loader->setClassMapAuthoritative(true);
$loader->register(true);
$includeFiles = \Composer\Autoload\ComposerStaticInit856beaf073331b6a66817a28e08a58fc::$files;
$includeFiles = \Composer\Autoload\ComposerStaticInita71e3fc1f9700a5d679aa07e296cbdbd::$files;
foreach ($includeFiles as $fileIdentifier => $file) {
composerRequire856beaf073331b6a66817a28e08a58fc($fileIdentifier, $file);
composerRequirea71e3fc1f9700a5d679aa07e296cbdbd($fileIdentifier, $file);
}
return $loader;
@ -46,7 +46,7 @@ class ComposerAutoloaderInit856beaf073331b6a66817a28e08a58fc
* @param string $file
* @return void
*/
function composerRequire856beaf073331b6a66817a28e08a58fc($fileIdentifier, $file)
function composerRequirea71e3fc1f9700a5d679aa07e296cbdbd($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 ComposerStaticInit856beaf073331b6a66817a28e08a58fc
class ComposerStaticInita71e3fc1f9700a5d679aa07e296cbdbd
{
public static $files = array (
'ad155f8f1cf0d418fe49e248db8c661b' => __DIR__ . '/..' . '/react/promise/src/functions_include.php',
@ -3032,9 +3032,9 @@ class ComposerStaticInit856beaf073331b6a66817a28e08a58fc
public static function getInitializer(ClassLoader $loader)
{
return \Closure::bind(function () use ($loader) {
$loader->prefixLengthsPsr4 = ComposerStaticInit856beaf073331b6a66817a28e08a58fc::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInit856beaf073331b6a66817a28e08a58fc::$prefixDirsPsr4;
$loader->classMap = ComposerStaticInit856beaf073331b6a66817a28e08a58fc::$classMap;
$loader->prefixLengthsPsr4 = ComposerStaticInita71e3fc1f9700a5d679aa07e296cbdbd::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInita71e3fc1f9700a5d679aa07e296cbdbd::$prefixDirsPsr4;
$loader->classMap = ComposerStaticInita71e3fc1f9700a5d679aa07e296cbdbd::$classMap;
}, null, ClassLoader::class);
}