Updated Rector to commit f90acd4c3ab5541e65dfd49566d6680db9d929d9

f90acd4c3a [DowngradePhp80] Handle inside Closure on DowngradeMatchToSwitchRector (#2333)
This commit is contained in:
Tomas Votruba 2022-05-19 14:31:37 +00:00
parent ce9b1cc6e6
commit aff4495016
6 changed files with 31 additions and 28 deletions

View File

@ -101,7 +101,11 @@ CODE_SAMPLE
if (!$match instanceof \PhpParser\Node\Expr\Match_) {
return null;
}
$switchCases = $this->createSwitchCasesFromMatchArms($node, $match->arms);
$currentStmt = $this->betterNodeFinder->resolveCurrentStatement($match);
if ($currentStmt !== $node) {
return null;
}
$switchCases = $this->createSwitchCasesFromMatchArms($node, $match);
$switch = new \PhpParser\Node\Stmt\Switch_($match->cond, $switchCases);
$parentMatch = $match->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PARENT_NODE);
if ($parentMatch instanceof \PhpParser\Node\Expr\ArrowFunction) {
@ -144,14 +148,14 @@ CODE_SAMPLE
return null;
}
/**
* @param MatchArm[] $matchArms
* @return Case_[]
* @param \PhpParser\Node\Stmt\Echo_|\PhpParser\Node\Stmt\Expression|\PhpParser\Node\Stmt\Return_ $node
*/
private function createSwitchCasesFromMatchArms($node, array $matchArms) : array
private function createSwitchCasesFromMatchArms($node, \PhpParser\Node\Expr\Match_ $match) : array
{
$switchCases = [];
foreach ($matchArms as $matchArm) {
$parentNode = $match->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PARENT_NODE);
foreach ($match->arms as $matchArm) {
if (\count((array) $matchArm->conds) > 1) {
$lastCase = null;
foreach ((array) $matchArm->conds as $matchArmCond) {
@ -161,9 +165,9 @@ CODE_SAMPLE
if (!$lastCase instanceof \PhpParser\Node\Stmt\Case_) {
throw new \Rector\Core\Exception\ShouldNotHappenException();
}
$lastCase->stmts = $this->createSwitchStmts($node, $matchArm);
$lastCase->stmts = $this->createSwitchStmts($node, $matchArm, $parentNode);
} else {
$stmts = $this->createSwitchStmts($node, $matchArm);
$stmts = $this->createSwitchStmts($node, $matchArm, $parentNode);
$switchCases[] = new \PhpParser\Node\Stmt\Case_($matchArm->conds[0] ?? null, $stmts);
}
}
@ -173,11 +177,10 @@ CODE_SAMPLE
* @return Stmt[]
* @param \PhpParser\Node\Stmt\Echo_|\PhpParser\Node\Stmt\Expression|\PhpParser\Node\Stmt\Return_ $node
*/
private function createSwitchStmts($node, \PhpParser\Node\MatchArm $matchArm) : array
private function createSwitchStmts($node, \PhpParser\Node\MatchArm $matchArm, ?\PhpParser\Node $parentNode) : array
{
$stmts = [];
$parentArrayItem = $this->betterNodeFinder->findParentType($matchArm, \PhpParser\Node\Expr\ArrayItem::class);
if ($parentArrayItem instanceof \PhpParser\Node\Expr\ArrayItem) {
if ($parentNode instanceof \PhpParser\Node\Expr\ArrayItem) {
$stmts[] = new \PhpParser\Node\Stmt\Return_($matchArm->body);
} elseif ($matchArm->body instanceof \PhpParser\Node\Expr\Throw_) {
$stmts[] = new \PhpParser\Node\Stmt\Expression($matchArm->body);

View File

@ -16,11 +16,11 @@ final class VersionResolver
/**
* @var string
*/
public const PACKAGE_VERSION = '30a53bfd939afef66afb1e0d71d5b2583eda0693';
public const PACKAGE_VERSION = 'f90acd4c3ab5541e65dfd49566d6680db9d929d9';
/**
* @var string
*/
public const RELEASE_DATE = '2022-05-19 08:52:59';
public const RELEASE_DATE = '2022-05-19 21:25:28';
/**
* @var string
*/

2
vendor/autoload.php vendored
View File

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

View File

@ -2,7 +2,7 @@
// autoload_real.php @generated by Composer
class ComposerAutoloaderInitb7815d4fca084bf85e339420083834b3
class ComposerAutoloaderInit278000ff8d716d1a065e7d4ed8beb64b
{
private static $loader;
@ -22,19 +22,19 @@ class ComposerAutoloaderInitb7815d4fca084bf85e339420083834b3
return self::$loader;
}
spl_autoload_register(array('ComposerAutoloaderInitb7815d4fca084bf85e339420083834b3', 'loadClassLoader'), true, true);
spl_autoload_register(array('ComposerAutoloaderInit278000ff8d716d1a065e7d4ed8beb64b', 'loadClassLoader'), true, true);
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__));
spl_autoload_unregister(array('ComposerAutoloaderInitb7815d4fca084bf85e339420083834b3', 'loadClassLoader'));
spl_autoload_unregister(array('ComposerAutoloaderInit278000ff8d716d1a065e7d4ed8beb64b', 'loadClassLoader'));
require __DIR__ . '/autoload_static.php';
call_user_func(\Composer\Autoload\ComposerStaticInitb7815d4fca084bf85e339420083834b3::getInitializer($loader));
call_user_func(\Composer\Autoload\ComposerStaticInit278000ff8d716d1a065e7d4ed8beb64b::getInitializer($loader));
$loader->setClassMapAuthoritative(true);
$loader->register(true);
$includeFiles = \Composer\Autoload\ComposerStaticInitb7815d4fca084bf85e339420083834b3::$files;
$includeFiles = \Composer\Autoload\ComposerStaticInit278000ff8d716d1a065e7d4ed8beb64b::$files;
foreach ($includeFiles as $fileIdentifier => $file) {
composerRequireb7815d4fca084bf85e339420083834b3($fileIdentifier, $file);
composerRequire278000ff8d716d1a065e7d4ed8beb64b($fileIdentifier, $file);
}
return $loader;
@ -46,7 +46,7 @@ class ComposerAutoloaderInitb7815d4fca084bf85e339420083834b3
* @param string $file
* @return void
*/
function composerRequireb7815d4fca084bf85e339420083834b3($fileIdentifier, $file)
function composerRequire278000ff8d716d1a065e7d4ed8beb64b($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 ComposerStaticInitb7815d4fca084bf85e339420083834b3
class ComposerStaticInit278000ff8d716d1a065e7d4ed8beb64b
{
public static $files = array (
'320cde22f66dd4f5d3fd621d3e88b98f' => __DIR__ . '/..' . '/symfony/polyfill-ctype/bootstrap.php',
@ -3907,9 +3907,9 @@ class ComposerStaticInitb7815d4fca084bf85e339420083834b3
public static function getInitializer(ClassLoader $loader)
{
return \Closure::bind(function () use ($loader) {
$loader->prefixLengthsPsr4 = ComposerStaticInitb7815d4fca084bf85e339420083834b3::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInitb7815d4fca084bf85e339420083834b3::$prefixDirsPsr4;
$loader->classMap = ComposerStaticInitb7815d4fca084bf85e339420083834b3::$classMap;
$loader->prefixLengthsPsr4 = ComposerStaticInit278000ff8d716d1a065e7d4ed8beb64b::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInit278000ff8d716d1a065e7d4ed8beb64b::$prefixDirsPsr4;
$loader->classMap = ComposerStaticInit278000ff8d716d1a065e7d4ed8beb64b::$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('RectorPrefix20220519\AutoloadIncluder');
}
if (!class_exists('ComposerAutoloaderInitb7815d4fca084bf85e339420083834b3', false) && !interface_exists('ComposerAutoloaderInitb7815d4fca084bf85e339420083834b3', false) && !trait_exists('ComposerAutoloaderInitb7815d4fca084bf85e339420083834b3', false)) {
spl_autoload_call('RectorPrefix20220519\ComposerAutoloaderInitb7815d4fca084bf85e339420083834b3');
if (!class_exists('ComposerAutoloaderInit278000ff8d716d1a065e7d4ed8beb64b', false) && !interface_exists('ComposerAutoloaderInit278000ff8d716d1a065e7d4ed8beb64b', false) && !trait_exists('ComposerAutoloaderInit278000ff8d716d1a065e7d4ed8beb64b', false)) {
spl_autoload_call('RectorPrefix20220519\ComposerAutoloaderInit278000ff8d716d1a065e7d4ed8beb64b');
}
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('RectorPrefix20220519\Helmich\TypoScriptParser\Parser\AST\Statement');
@ -59,9 +59,9 @@ if (!function_exists('print_node')) {
return \RectorPrefix20220519\print_node(...func_get_args());
}
}
if (!function_exists('composerRequireb7815d4fca084bf85e339420083834b3')) {
function composerRequireb7815d4fca084bf85e339420083834b3() {
return \RectorPrefix20220519\composerRequireb7815d4fca084bf85e339420083834b3(...func_get_args());
if (!function_exists('composerRequire278000ff8d716d1a065e7d4ed8beb64b')) {
function composerRequire278000ff8d716d1a065e7d4ed8beb64b() {
return \RectorPrefix20220519\composerRequire278000ff8d716d1a065e7d4ed8beb64b(...func_get_args());
}
}
if (!function_exists('scanPath')) {