Updated Rector to commit 22f121a671b2c779e8e3ec6471c14d4a3321631d

22f121a671 [Php56] Handle infinite loop on big array method call on AddDefaultValueForUndefinedVariableRector (#4142)
This commit is contained in:
Tomas Votruba 2023-06-09 17:04:50 +00:00
parent 8135dd31be
commit 17487f2df7
5 changed files with 24 additions and 16 deletions

View File

@ -74,7 +74,8 @@ final class UndefinedVariableResolver
public function resolve($node) : array public function resolve($node) : array
{ {
$undefinedVariables = []; $undefinedVariables = [];
$this->simpleCallableNodeTraverser->traverseNodesWithCallable((array) $node->stmts, function (Node $node) use(&$undefinedVariables) : ?int { $checkedVariables = [];
$this->simpleCallableNodeTraverser->traverseNodesWithCallable((array) $node->stmts, function (Node $node) use(&$undefinedVariables, &$checkedVariables) : ?int {
// entering new scope - break! // entering new scope - break!
if ($node instanceof FunctionLike && !$node instanceof ArrowFunction) { if ($node instanceof FunctionLike && !$node instanceof ArrowFunction) {
return NodeTraverser::DONT_TRAVERSE_CURRENT_AND_CHILDREN; return NodeTraverser::DONT_TRAVERSE_CURRENT_AND_CHILDREN;
@ -90,10 +91,10 @@ final class UndefinedVariableResolver
if (!$parentNode instanceof Node) { if (!$parentNode instanceof Node) {
return null; return null;
} }
if ($this->shouldSkipVariable($node, $parentNode)) { $variableName = (string) $this->nodeNameResolver->getName($node);
if ($this->shouldSkipVariable($node, $variableName, $checkedVariables, $parentNode)) {
return null; return null;
} }
$variableName = $this->nodeNameResolver->getName($node);
if ($this->hasVariableTypeOrCurrentStmtUnreachable($node, $variableName)) { if ($this->hasVariableTypeOrCurrentStmtUnreachable($node, $variableName)) {
return null; return null;
} }
@ -140,7 +141,10 @@ final class UndefinedVariableResolver
{ {
return \in_array(\get_class($parentNode), [Assign::class, AssignRef::class], \true); return \in_array(\get_class($parentNode), [Assign::class, AssignRef::class], \true);
} }
private function shouldSkipVariable(Variable $variable, Node $parentNode) : bool /**
* @param string[] $checkedVariables
*/
private function shouldSkipVariable(Variable $variable, string $variableName, array &$checkedVariables, Node $parentNode) : bool
{ {
if ($this->isAsCoalesceLeftOrAssignOpCoalesceVar($parentNode, $variable)) { if ($this->isAsCoalesceLeftOrAssignOpCoalesceVar($parentNode, $variable)) {
return \true; return \true;
@ -169,6 +173,10 @@ final class UndefinedVariableResolver
if ($this->variableAnalyzer->isStaticOrGlobal($variable)) { if ($this->variableAnalyzer->isStaticOrGlobal($variable)) {
return \true; return \true;
} }
if (\in_array($variableName, $checkedVariables, \true)) {
return \true;
}
$checkedVariables[] = $variableName;
if ($this->hasPreviousCheckedWithIsset($variable)) { if ($this->hasPreviousCheckedWithIsset($variable)) {
return \true; return \true;
} }

View File

@ -19,12 +19,12 @@ final class VersionResolver
* @api * @api
* @var string * @var string
*/ */
public const PACKAGE_VERSION = '27ac0efdca63485c6e0ee27086cda9bc7b2e6c17'; public const PACKAGE_VERSION = '22f121a671b2c779e8e3ec6471c14d4a3321631d';
/** /**
* @api * @api
* @var string * @var string
*/ */
public const RELEASE_DATE = '2023-06-09 16:18:11'; public const RELEASE_DATE = '2023-06-09 16:59:55';
/** /**
* @var int * @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'; require_once __DIR__ . '/composer/autoload_real.php';
return ComposerAutoloaderInitdbb9ba42e4c01bc09b28ae467199df0b::getLoader(); return ComposerAutoloaderInita684d2c132f2c1a3670e36ee6392171c::getLoader();

View File

@ -2,7 +2,7 @@
// autoload_real.php @generated by Composer // autoload_real.php @generated by Composer
class ComposerAutoloaderInitdbb9ba42e4c01bc09b28ae467199df0b class ComposerAutoloaderInita684d2c132f2c1a3670e36ee6392171c
{ {
private static $loader; private static $loader;
@ -22,17 +22,17 @@ class ComposerAutoloaderInitdbb9ba42e4c01bc09b28ae467199df0b
return self::$loader; return self::$loader;
} }
spl_autoload_register(array('ComposerAutoloaderInitdbb9ba42e4c01bc09b28ae467199df0b', 'loadClassLoader'), true, true); spl_autoload_register(array('ComposerAutoloaderInita684d2c132f2c1a3670e36ee6392171c', 'loadClassLoader'), true, true);
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__)); self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__));
spl_autoload_unregister(array('ComposerAutoloaderInitdbb9ba42e4c01bc09b28ae467199df0b', 'loadClassLoader')); spl_autoload_unregister(array('ComposerAutoloaderInita684d2c132f2c1a3670e36ee6392171c', 'loadClassLoader'));
require __DIR__ . '/autoload_static.php'; require __DIR__ . '/autoload_static.php';
call_user_func(\Composer\Autoload\ComposerStaticInitdbb9ba42e4c01bc09b28ae467199df0b::getInitializer($loader)); call_user_func(\Composer\Autoload\ComposerStaticInita684d2c132f2c1a3670e36ee6392171c::getInitializer($loader));
$loader->setClassMapAuthoritative(true); $loader->setClassMapAuthoritative(true);
$loader->register(true); $loader->register(true);
$filesToLoad = \Composer\Autoload\ComposerStaticInitdbb9ba42e4c01bc09b28ae467199df0b::$files; $filesToLoad = \Composer\Autoload\ComposerStaticInita684d2c132f2c1a3670e36ee6392171c::$files;
$requireFile = \Closure::bind(static function ($fileIdentifier, $file) { $requireFile = \Closure::bind(static function ($fileIdentifier, $file) {
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) { if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
$GLOBALS['__composer_autoload_files'][$fileIdentifier] = true; $GLOBALS['__composer_autoload_files'][$fileIdentifier] = true;

View File

@ -4,7 +4,7 @@
namespace Composer\Autoload; namespace Composer\Autoload;
class ComposerStaticInitdbb9ba42e4c01bc09b28ae467199df0b class ComposerStaticInita684d2c132f2c1a3670e36ee6392171c
{ {
public static $files = array ( public static $files = array (
'ad155f8f1cf0d418fe49e248db8c661b' => __DIR__ . '/..' . '/react/promise/src/functions_include.php', 'ad155f8f1cf0d418fe49e248db8c661b' => __DIR__ . '/..' . '/react/promise/src/functions_include.php',
@ -3128,9 +3128,9 @@ class ComposerStaticInitdbb9ba42e4c01bc09b28ae467199df0b
public static function getInitializer(ClassLoader $loader) public static function getInitializer(ClassLoader $loader)
{ {
return \Closure::bind(function () use ($loader) { return \Closure::bind(function () use ($loader) {
$loader->prefixLengthsPsr4 = ComposerStaticInitdbb9ba42e4c01bc09b28ae467199df0b::$prefixLengthsPsr4; $loader->prefixLengthsPsr4 = ComposerStaticInita684d2c132f2c1a3670e36ee6392171c::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInitdbb9ba42e4c01bc09b28ae467199df0b::$prefixDirsPsr4; $loader->prefixDirsPsr4 = ComposerStaticInita684d2c132f2c1a3670e36ee6392171c::$prefixDirsPsr4;
$loader->classMap = ComposerStaticInitdbb9ba42e4c01bc09b28ae467199df0b::$classMap; $loader->classMap = ComposerStaticInita684d2c132f2c1a3670e36ee6392171c::$classMap;
}, null, ClassLoader::class); }, null, ClassLoader::class);
} }