mirror of
https://github.com/rectorphp/rector.git
synced 2025-01-19 06:18:07 +01:00
Updated Rector to commit 369c2f7dfe77f93ea1d650270e502e1471b28128
369c2f7dfe
[CodeQuality][EarlyReturn] Handle SimplifyIfElseToTernaryRector + ChangeIfElseValueAssignToEarlyReturnRector (#1710)
This commit is contained in:
parent
97621fb485
commit
62081a03cc
@ -11,7 +11,9 @@ use PhpParser\Node\Expr\Ternary;
|
||||
use PhpParser\Node\Stmt;
|
||||
use PhpParser\Node\Stmt\Expression;
|
||||
use PhpParser\Node\Stmt\If_;
|
||||
use PhpParser\Node\Stmt\Return_;
|
||||
use Rector\Core\Rector\AbstractRector;
|
||||
use Rector\NodeTypeResolver\Node\AttributeKey;
|
||||
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
|
||||
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
|
||||
/**
|
||||
@ -96,10 +98,29 @@ CODE_SAMPLE
|
||||
if ($this->isNodeTooLong($assign)) {
|
||||
return null;
|
||||
}
|
||||
if ($this->isNextReturnRemoved($node, $ifAssignVar)) {
|
||||
return null;
|
||||
}
|
||||
$expression = new \PhpParser\Node\Stmt\Expression($assign);
|
||||
$this->mirrorComments($expression, $node);
|
||||
return $expression;
|
||||
}
|
||||
private function isNextReturnRemoved(\PhpParser\Node\Stmt\If_ $if, \PhpParser\Node\Expr $expr) : bool
|
||||
{
|
||||
if (!$this->nodesToRemoveCollector->isActive()) {
|
||||
return \false;
|
||||
}
|
||||
$next = $if->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::NEXT_NODE);
|
||||
if ($next instanceof \PhpParser\Node\Stmt\Return_ && $next->expr instanceof \PhpParser\Node\Expr && $this->nodeComparator->areNodesEqual($next->expr, $expr)) {
|
||||
$nodesToRemove = $this->nodesToRemoveCollector->getNodesToRemove();
|
||||
foreach ($nodesToRemove as $nodeToRemove) {
|
||||
if ($this->nodeComparator->areNodesEqual($next, $nodeToRemove)) {
|
||||
return \true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return \false;
|
||||
}
|
||||
/**
|
||||
* @param Stmt[] $stmts
|
||||
*/
|
||||
|
@ -16,11 +16,11 @@ final class VersionResolver
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public const PACKAGE_VERSION = 'cb96224c93e78c462c86849b96a0255d71832a45';
|
||||
public const PACKAGE_VERSION = '369c2f7dfe77f93ea1d650270e502e1471b28128';
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public const RELEASE_DATE = '2022-01-22 00:00:30';
|
||||
public const RELEASE_DATE = '2022-01-22 06:32:25';
|
||||
public static function resolvePackageVersion() : string
|
||||
{
|
||||
$process = new \RectorPrefix20220121\Symfony\Component\Process\Process(['git', 'log', '--pretty="%H"', '-n1', 'HEAD'], __DIR__);
|
||||
|
2
vendor/autoload.php
vendored
2
vendor/autoload.php
vendored
@ -4,4 +4,4 @@
|
||||
|
||||
require_once __DIR__ . '/composer/autoload_real.php';
|
||||
|
||||
return ComposerAutoloaderInit4d68abbe72d40a5a84ab4cca9ce302f8::getLoader();
|
||||
return ComposerAutoloaderInitfa2e369211173af7834fd8ed41a3375f::getLoader();
|
||||
|
14
vendor/composer/autoload_real.php
vendored
14
vendor/composer/autoload_real.php
vendored
@ -2,7 +2,7 @@
|
||||
|
||||
// autoload_real.php @generated by Composer
|
||||
|
||||
class ComposerAutoloaderInit4d68abbe72d40a5a84ab4cca9ce302f8
|
||||
class ComposerAutoloaderInitfa2e369211173af7834fd8ed41a3375f
|
||||
{
|
||||
private static $loader;
|
||||
|
||||
@ -22,15 +22,15 @@ class ComposerAutoloaderInit4d68abbe72d40a5a84ab4cca9ce302f8
|
||||
return self::$loader;
|
||||
}
|
||||
|
||||
spl_autoload_register(array('ComposerAutoloaderInit4d68abbe72d40a5a84ab4cca9ce302f8', 'loadClassLoader'), true, true);
|
||||
spl_autoload_register(array('ComposerAutoloaderInitfa2e369211173af7834fd8ed41a3375f', 'loadClassLoader'), true, true);
|
||||
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(\dirname(__FILE__)));
|
||||
spl_autoload_unregister(array('ComposerAutoloaderInit4d68abbe72d40a5a84ab4cca9ce302f8', 'loadClassLoader'));
|
||||
spl_autoload_unregister(array('ComposerAutoloaderInitfa2e369211173af7834fd8ed41a3375f', '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\ComposerStaticInit4d68abbe72d40a5a84ab4cca9ce302f8::getInitializer($loader));
|
||||
call_user_func(\Composer\Autoload\ComposerStaticInitfa2e369211173af7834fd8ed41a3375f::getInitializer($loader));
|
||||
} else {
|
||||
$classMap = require __DIR__ . '/autoload_classmap.php';
|
||||
if ($classMap) {
|
||||
@ -42,12 +42,12 @@ class ComposerAutoloaderInit4d68abbe72d40a5a84ab4cca9ce302f8
|
||||
$loader->register(true);
|
||||
|
||||
if ($useStaticLoader) {
|
||||
$includeFiles = Composer\Autoload\ComposerStaticInit4d68abbe72d40a5a84ab4cca9ce302f8::$files;
|
||||
$includeFiles = Composer\Autoload\ComposerStaticInitfa2e369211173af7834fd8ed41a3375f::$files;
|
||||
} else {
|
||||
$includeFiles = require __DIR__ . '/autoload_files.php';
|
||||
}
|
||||
foreach ($includeFiles as $fileIdentifier => $file) {
|
||||
composerRequire4d68abbe72d40a5a84ab4cca9ce302f8($fileIdentifier, $file);
|
||||
composerRequirefa2e369211173af7834fd8ed41a3375f($fileIdentifier, $file);
|
||||
}
|
||||
|
||||
return $loader;
|
||||
@ -59,7 +59,7 @@ class ComposerAutoloaderInit4d68abbe72d40a5a84ab4cca9ce302f8
|
||||
* @param string $file
|
||||
* @return void
|
||||
*/
|
||||
function composerRequire4d68abbe72d40a5a84ab4cca9ce302f8($fileIdentifier, $file)
|
||||
function composerRequirefa2e369211173af7834fd8ed41a3375f($fileIdentifier, $file)
|
||||
{
|
||||
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
|
||||
$GLOBALS['__composer_autoload_files'][$fileIdentifier] = true;
|
||||
|
8
vendor/composer/autoload_static.php
vendored
8
vendor/composer/autoload_static.php
vendored
@ -4,7 +4,7 @@
|
||||
|
||||
namespace Composer\Autoload;
|
||||
|
||||
class ComposerStaticInit4d68abbe72d40a5a84ab4cca9ce302f8
|
||||
class ComposerStaticInitfa2e369211173af7834fd8ed41a3375f
|
||||
{
|
||||
public static $files = array (
|
||||
'0e6d7bf4a5811bfa5cf40c5ccd6fae6a' => __DIR__ . '/..' . '/symfony/polyfill-mbstring/bootstrap.php',
|
||||
@ -3872,9 +3872,9 @@ class ComposerStaticInit4d68abbe72d40a5a84ab4cca9ce302f8
|
||||
public static function getInitializer(ClassLoader $loader)
|
||||
{
|
||||
return \Closure::bind(function () use ($loader) {
|
||||
$loader->prefixLengthsPsr4 = ComposerStaticInit4d68abbe72d40a5a84ab4cca9ce302f8::$prefixLengthsPsr4;
|
||||
$loader->prefixDirsPsr4 = ComposerStaticInit4d68abbe72d40a5a84ab4cca9ce302f8::$prefixDirsPsr4;
|
||||
$loader->classMap = ComposerStaticInit4d68abbe72d40a5a84ab4cca9ce302f8::$classMap;
|
||||
$loader->prefixLengthsPsr4 = ComposerStaticInitfa2e369211173af7834fd8ed41a3375f::$prefixLengthsPsr4;
|
||||
$loader->prefixDirsPsr4 = ComposerStaticInitfa2e369211173af7834fd8ed41a3375f::$prefixDirsPsr4;
|
||||
$loader->classMap = ComposerStaticInitfa2e369211173af7834fd8ed41a3375f::$classMap;
|
||||
|
||||
}, null, ClassLoader::class);
|
||||
}
|
||||
|
10
vendor/scoper-autoload.php
vendored
10
vendor/scoper-autoload.php
vendored
@ -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('RectorPrefix20220121\AutoloadIncluder');
|
||||
}
|
||||
if (!class_exists('ComposerAutoloaderInit4d68abbe72d40a5a84ab4cca9ce302f8', false) && !interface_exists('ComposerAutoloaderInit4d68abbe72d40a5a84ab4cca9ce302f8', false) && !trait_exists('ComposerAutoloaderInit4d68abbe72d40a5a84ab4cca9ce302f8', false)) {
|
||||
spl_autoload_call('RectorPrefix20220121\ComposerAutoloaderInit4d68abbe72d40a5a84ab4cca9ce302f8');
|
||||
if (!class_exists('ComposerAutoloaderInitfa2e369211173af7834fd8ed41a3375f', false) && !interface_exists('ComposerAutoloaderInitfa2e369211173af7834fd8ed41a3375f', false) && !trait_exists('ComposerAutoloaderInitfa2e369211173af7834fd8ed41a3375f', false)) {
|
||||
spl_autoload_call('RectorPrefix20220121\ComposerAutoloaderInitfa2e369211173af7834fd8ed41a3375f');
|
||||
}
|
||||
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('RectorPrefix20220121\Helmich\TypoScriptParser\Parser\AST\Statement');
|
||||
@ -71,9 +71,9 @@ if (!function_exists('print_node')) {
|
||||
return \RectorPrefix20220121\print_node(...func_get_args());
|
||||
}
|
||||
}
|
||||
if (!function_exists('composerRequire4d68abbe72d40a5a84ab4cca9ce302f8')) {
|
||||
function composerRequire4d68abbe72d40a5a84ab4cca9ce302f8() {
|
||||
return \RectorPrefix20220121\composerRequire4d68abbe72d40a5a84ab4cca9ce302f8(...func_get_args());
|
||||
if (!function_exists('composerRequirefa2e369211173af7834fd8ed41a3375f')) {
|
||||
function composerRequirefa2e369211173af7834fd8ed41a3375f() {
|
||||
return \RectorPrefix20220121\composerRequirefa2e369211173af7834fd8ed41a3375f(...func_get_args());
|
||||
}
|
||||
}
|
||||
if (!function_exists('scanPath')) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user