Updated Rector to commit 3f0a0b7259737f77c673c3e7c462a6530c0123f5

3f0a0b7259 [Php80] Skip no default return fluent on ChangeSwitchToMatchRector (#2334)
This commit is contained in:
Tomas Votruba 2022-05-19 16:31:50 +00:00
parent aff4495016
commit f2940cdc9c
6 changed files with 52 additions and 25 deletions

View File

@ -3,12 +3,16 @@
declare (strict_types=1);
namespace Rector\Php80\NodeAnalyzer;
use PhpParser\Node;
use PhpParser\Node\Expr;
use PhpParser\Node\Expr\ArrayDimFetch;
use PhpParser\Node\Expr\Assign;
use PhpParser\Node\Expr\Match_;
use PhpParser\Node\Stmt\Expression;
use PhpParser\Node\Stmt\Return_;
use PhpParser\Node\Stmt\Switch_;
use PhpParser\Node\Stmt\Throw_;
use Rector\Core\PhpParser\Comparing\NodeComparator;
use Rector\NodeNameResolver\NodeNameResolver;
use Rector\NodeTypeResolver\Node\AttributeKey;
use Rector\Php80\Enum\MatchKind;
@ -25,10 +29,16 @@ final class MatchSwitchAnalyzer
* @var \Rector\NodeNameResolver\NodeNameResolver
*/
private $nodeNameResolver;
public function __construct(\Rector\Php80\NodeAnalyzer\SwitchAnalyzer $switchAnalyzer, \Rector\NodeNameResolver\NodeNameResolver $nodeNameResolver)
/**
* @readonly
* @var \Rector\Core\PhpParser\Comparing\NodeComparator
*/
private $nodeComparator;
public function __construct(\Rector\Php80\NodeAnalyzer\SwitchAnalyzer $switchAnalyzer, \Rector\NodeNameResolver\NodeNameResolver $nodeNameResolver, \Rector\Core\PhpParser\Comparing\NodeComparator $nodeComparator)
{
$this->switchAnalyzer = $switchAnalyzer;
$this->nodeNameResolver = $nodeNameResolver;
$this->nodeComparator = $nodeComparator;
}
/**
* @param CondAndExpr[] $condAndExprs
@ -110,15 +120,32 @@ final class MatchSwitchAnalyzer
}
private function isNextStmtReturnWithExpr(\PhpParser\Node\Stmt\Switch_ $switch) : bool
{
$parent = $switch->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::NEXT_NODE);
if (!$parent instanceof \PhpParser\Node\Stmt\Return_) {
$next = $switch->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::NEXT_NODE);
if (!$next instanceof \PhpParser\Node\Stmt\Return_) {
return \false;
}
return $parent->expr !== null;
if (!$next->expr instanceof \PhpParser\Node\Expr) {
return \false;
}
foreach ($switch->cases as $case) {
/** @var Expression[] $expressions */
$expressions = \array_filter($case->stmts, function (\PhpParser\Node $node) : bool {
return $node instanceof \PhpParser\Node\Stmt\Expression;
});
foreach ($expressions as $expression) {
if (!$expression->expr instanceof \PhpParser\Node\Expr\Assign) {
continue;
}
if (!$this->nodeComparator->areNodesEqual($expression->expr->var, $next->expr)) {
return \false;
}
}
}
return \true;
}
private function isNextStmtThrows(\PhpParser\Node\Stmt\Switch_ $switch) : bool
{
$parent = $switch->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::NEXT_NODE);
return $parent instanceof \PhpParser\Node\Stmt\Throw_;
$next = $switch->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::NEXT_NODE);
return $next instanceof \PhpParser\Node\Stmt\Throw_;
}
}

View File

@ -16,11 +16,11 @@ final class VersionResolver
/**
* @var string
*/
public const PACKAGE_VERSION = 'f90acd4c3ab5541e65dfd49566d6680db9d929d9';
public const PACKAGE_VERSION = '3f0a0b7259737f77c673c3e7c462a6530c0123f5';
/**
* @var string
*/
public const RELEASE_DATE = '2022-05-19 21:25:28';
public const RELEASE_DATE = '2022-05-19 18:23:22';
/**
* @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 ComposerAutoloaderInit278000ff8d716d1a065e7d4ed8beb64b::getLoader();
return ComposerAutoloaderInit41157f8d50e36491d857618c080429c8::getLoader();

View File

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