Skip to content

Commit

Permalink
Updated Rector to commit 3f0a0b7
Browse files Browse the repository at this point in the history
rectorphp/rector-src@3f0a0b7 [Php80] Skip no default return fluent on ChangeSwitchToMatchRector (#2334)
  • Loading branch information
TomasVotruba committed May 19, 2022
1 parent aff4495 commit f2940cd
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 25 deletions.
39 changes: 33 additions & 6 deletions rules/Php80/NodeAnalyzer/MatchSwitchAnalyzer.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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
Expand Down Expand Up @@ -110,15 +120,32 @@ private function resolveUniqueKindsWithoutThrows(array $condAndExprs) : array
}
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_;
}
}
4 changes: 2 additions & 2 deletions src/Application/VersionResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down
2 changes: 1 addition & 1 deletion vendor/autoload.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@

require_once __DIR__ . '/composer/autoload_real.php';

return ComposerAutoloaderInit278000ff8d716d1a065e7d4ed8beb64b::getLoader();
return ComposerAutoloaderInit41157f8d50e36491d857618c080429c8::getLoader();
14 changes: 7 additions & 7 deletions vendor/composer/autoload_real.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

// autoload_real.php @generated by Composer

class ComposerAutoloaderInit278000ff8d716d1a065e7d4ed8beb64b
class ComposerAutoloaderInit41157f8d50e36491d857618c080429c8
{
private static $loader;

Expand All @@ -22,19 +22,19 @@ public static function getLoader()
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;
Expand All @@ -46,7 +46,7 @@ public static function getLoader()
* @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;
Expand Down
8 changes: 4 additions & 4 deletions vendor/composer/autoload_static.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace Composer\Autoload;

class ComposerStaticInit278000ff8d716d1a065e7d4ed8beb64b
class ComposerStaticInit41157f8d50e36491d857618c080429c8
{
public static $files = array (
'320cde22f66dd4f5d3fd621d3e88b98f' => __DIR__ . '/..' . '/symfony/polyfill-ctype/bootstrap.php',
Expand Down Expand Up @@ -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);
}
Expand Down
10 changes: 5 additions & 5 deletions vendor/scoper-autoload.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
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');
Expand Down Expand Up @@ -59,9 +59,9 @@ function 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')) {
Expand Down

0 comments on commit f2940cd

Please sign in to comment.