Updated Rector to commit ccd8e898af997a1a21af6159c6b85f04ab418552

ccd8e898af [Naming][Php56] Handle AddDefaultValueForUndefinedVariableRector + RenameParamToMatchTypeRector (#993)
This commit is contained in:
Tomas Votruba 2021-10-12 12:52:00 +00:00
parent b45a2137a9
commit ebd0863c09
6 changed files with 38 additions and 20 deletions

View File

@ -47,7 +47,8 @@ final class UndefinedVariableResolver
public function resolve($node) : array
{
$undefinedVariables = [];
$this->simpleCallableNodeTraverser->traverseNodesWithCallable((array) $node->stmts, function (\PhpParser\Node $node) use(&$undefinedVariables) : ?int {
$variableNamesFromParams = $this->collectVariableNamesFromParams($node);
$this->simpleCallableNodeTraverser->traverseNodesWithCallable((array) $node->stmts, function (\PhpParser\Node $node) use(&$undefinedVariables, $variableNamesFromParams) : ?int {
// entering new scope - break!
if ($node instanceof \PhpParser\Node\FunctionLike && !$node instanceof \PhpParser\Node\Expr\ArrowFunction) {
return \PhpParser\NodeTraverser::STOP_TRAVERSAL;
@ -70,11 +71,28 @@ final class UndefinedVariableResolver
if ($scope->hasVariableType($variableName)->yes()) {
return null;
}
if (\in_array($variableName, $variableNamesFromParams, \true)) {
return null;
}
$undefinedVariables[] = $variableName;
return null;
});
return \array_unique($undefinedVariables);
}
/**
* @return string[]
* @param \PhpParser\Node\Stmt\ClassMethod|\PhpParser\Node\Stmt\Function_|\PhpParser\Node\Expr\Closure $node
*/
private function collectVariableNamesFromParams($node) : array
{
$variableNames = [];
foreach ($node->getParams() as $param) {
if ($param->var instanceof \PhpParser\Node\Expr\Variable) {
$variableNames[] = (string) $this->nodeNameResolver->getName($param->var);
}
}
return $variableNames;
}
private function shouldSkipVariable(\PhpParser\Node\Expr\Variable $variable) : bool
{
$parentNode = $variable->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PARENT_NODE);

View File

@ -16,11 +16,11 @@ final class VersionResolver
/**
* @var string
*/
public const PACKAGE_VERSION = '2d6dba4055c239757c0d42dc09be955174ef7415';
public const PACKAGE_VERSION = 'ccd8e898af997a1a21af6159c6b85f04ab418552';
/**
* @var string
*/
public const RELEASE_DATE = '2021-10-12 09:27:15';
public const RELEASE_DATE = '2021-10-12 14:38:54';
public static function resolvePackageVersion() : string
{
$process = new \RectorPrefix20211012\Symfony\Component\Process\Process(['git', 'log', '--pretty="%H"', '-n1', 'HEAD'], __DIR__);

2
vendor/autoload.php vendored
View File

@ -4,4 +4,4 @@
require_once __DIR__ . '/composer/autoload_real.php';
return ComposerAutoloaderInit69d89db6affef9ba6843514e201c60ec::getLoader();
return ComposerAutoloaderInitef59f30913ed35ecd872c11628409872::getLoader();

View File

@ -2,7 +2,7 @@
// autoload_real.php @generated by Composer
class ComposerAutoloaderInit69d89db6affef9ba6843514e201c60ec
class ComposerAutoloaderInitef59f30913ed35ecd872c11628409872
{
private static $loader;
@ -22,15 +22,15 @@ class ComposerAutoloaderInit69d89db6affef9ba6843514e201c60ec
return self::$loader;
}
spl_autoload_register(array('ComposerAutoloaderInit69d89db6affef9ba6843514e201c60ec', 'loadClassLoader'), true, true);
spl_autoload_register(array('ComposerAutoloaderInitef59f30913ed35ecd872c11628409872', 'loadClassLoader'), true, true);
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(\dirname(__FILE__)));
spl_autoload_unregister(array('ComposerAutoloaderInit69d89db6affef9ba6843514e201c60ec', 'loadClassLoader'));
spl_autoload_unregister(array('ComposerAutoloaderInitef59f30913ed35ecd872c11628409872', 'loadClassLoader'));
$useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded());
if ($useStaticLoader) {
require __DIR__ . '/autoload_static.php';
call_user_func(\Composer\Autoload\ComposerStaticInit69d89db6affef9ba6843514e201c60ec::getInitializer($loader));
call_user_func(\Composer\Autoload\ComposerStaticInitef59f30913ed35ecd872c11628409872::getInitializer($loader));
} else {
$classMap = require __DIR__ . '/autoload_classmap.php';
if ($classMap) {
@ -42,19 +42,19 @@ class ComposerAutoloaderInit69d89db6affef9ba6843514e201c60ec
$loader->register(true);
if ($useStaticLoader) {
$includeFiles = Composer\Autoload\ComposerStaticInit69d89db6affef9ba6843514e201c60ec::$files;
$includeFiles = Composer\Autoload\ComposerStaticInitef59f30913ed35ecd872c11628409872::$files;
} else {
$includeFiles = require __DIR__ . '/autoload_files.php';
}
foreach ($includeFiles as $fileIdentifier => $file) {
composerRequire69d89db6affef9ba6843514e201c60ec($fileIdentifier, $file);
composerRequireef59f30913ed35ecd872c11628409872($fileIdentifier, $file);
}
return $loader;
}
}
function composerRequire69d89db6affef9ba6843514e201c60ec($fileIdentifier, $file)
function composerRequireef59f30913ed35ecd872c11628409872($fileIdentifier, $file)
{
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
require $file;

View File

@ -4,7 +4,7 @@
namespace Composer\Autoload;
class ComposerStaticInit69d89db6affef9ba6843514e201c60ec
class ComposerStaticInitef59f30913ed35ecd872c11628409872
{
public static $files = array (
'a4a119a56e50fbb293281d9a48007e0e' => __DIR__ . '/..' . '/symfony/polyfill-php80/bootstrap.php',
@ -3891,9 +3891,9 @@ class ComposerStaticInit69d89db6affef9ba6843514e201c60ec
public static function getInitializer(ClassLoader $loader)
{
return \Closure::bind(function () use ($loader) {
$loader->prefixLengthsPsr4 = ComposerStaticInit69d89db6affef9ba6843514e201c60ec::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInit69d89db6affef9ba6843514e201c60ec::$prefixDirsPsr4;
$loader->classMap = ComposerStaticInit69d89db6affef9ba6843514e201c60ec::$classMap;
$loader->prefixLengthsPsr4 = ComposerStaticInitef59f30913ed35ecd872c11628409872::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInitef59f30913ed35ecd872c11628409872::$prefixDirsPsr4;
$loader->classMap = ComposerStaticInitef59f30913ed35ecd872c11628409872::$classMap;
}, null, ClassLoader::class);
}

View File

@ -9,8 +9,8 @@ $loader = require_once __DIR__.'/autoload.php';
if (!class_exists('AutoloadIncluder', false) && !interface_exists('AutoloadIncluder', false) && !trait_exists('AutoloadIncluder', false)) {
spl_autoload_call('RectorPrefix20211012\AutoloadIncluder');
}
if (!class_exists('ComposerAutoloaderInit69d89db6affef9ba6843514e201c60ec', false) && !interface_exists('ComposerAutoloaderInit69d89db6affef9ba6843514e201c60ec', false) && !trait_exists('ComposerAutoloaderInit69d89db6affef9ba6843514e201c60ec', false)) {
spl_autoload_call('RectorPrefix20211012\ComposerAutoloaderInit69d89db6affef9ba6843514e201c60ec');
if (!class_exists('ComposerAutoloaderInitef59f30913ed35ecd872c11628409872', false) && !interface_exists('ComposerAutoloaderInitef59f30913ed35ecd872c11628409872', false) && !trait_exists('ComposerAutoloaderInitef59f30913ed35ecd872c11628409872', false)) {
spl_autoload_call('RectorPrefix20211012\ComposerAutoloaderInitef59f30913ed35ecd872c11628409872');
}
if (!class_exists('Helmich\TypoScriptParser\Parser\AST\Statement', false) && !interface_exists('Helmich\TypoScriptParser\Parser\AST\Statement', false) && !trait_exists('Helmich\TypoScriptParser\Parser\AST\Statement', false)) {
spl_autoload_call('RectorPrefix20211012\Helmich\TypoScriptParser\Parser\AST\Statement');
@ -3306,9 +3306,9 @@ if (!function_exists('print_node')) {
return \RectorPrefix20211012\print_node(...func_get_args());
}
}
if (!function_exists('composerRequire69d89db6affef9ba6843514e201c60ec')) {
function composerRequire69d89db6affef9ba6843514e201c60ec() {
return \RectorPrefix20211012\composerRequire69d89db6affef9ba6843514e201c60ec(...func_get_args());
if (!function_exists('composerRequireef59f30913ed35ecd872c11628409872')) {
function composerRequireef59f30913ed35ecd872c11628409872() {
return \RectorPrefix20211012\composerRequireef59f30913ed35ecd872c11628409872(...func_get_args());
}
}
if (!function_exists('parseArgs')) {