Updated Rector to commit 4d60c23f7c

4d60c23f7c [EarlyReturn] Skip same return expr on ChangeOrIfReturnToEarlyReturnRector (#797)
This commit is contained in:
Tomas Votruba 2021-08-31 13:04:35 +00:00
parent 13cd556d23
commit d5b84771d3
7 changed files with 34 additions and 28 deletions

View File

@ -80,12 +80,10 @@ CODE_SAMPLE
$this->changeDocObjectWithoutClassType($paramType, $key, $phpDocInfo);
}
}
if (!$phpDocInfo->hasChanged()) {
return null;
if ($phpDocInfo->hasChanged()) {
$node->setAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::HAS_PHP_DOC_INFO_JUST_CHANGED, \true);
return $node;
}
$node->setAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::HAS_PHP_DOC_INFO_JUST_CHANGED, \true);
// @see https://github.com/rectorphp/rector-src/pull/795
// avoid duplicated ifs and returns when combined with ChangeOrIfReturnToEarlyReturnRector, ChangeAndIfToEarlyReturnRector, and AddArrayReturnDocTypeRector
return null;
}
private function changeDocObjectWithoutClassType(\PHPStan\Type\UnionType $unionType, int $key, \Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo $phpDocInfo) : void

View File

@ -82,14 +82,15 @@ CODE_SAMPLE
return null;
}
$nextNode = $node->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::NEXT_NODE);
if ($nextNode === null) {
return null;
}
if ($nextNode instanceof \PhpParser\Node\Stmt\Return_ && $nextNode->expr === null) {
if ($this->shouldSkip($nextNode)) {
return null;
}
/** @var Return_ $return */
$return = $node->stmts[0];
// avoid repetitive ifs combined with other rules
if ($nextNode instanceof \PhpParser\Node\Stmt\Return_ && $this->nodeComparator->areNodesEqual($nextNode->expr, $return->expr)) {
return null;
}
$ifs = $this->createMultipleIfs($node->cond, $return, []);
foreach ($ifs as $key => $if) {
if ($key === 0) {
@ -100,6 +101,13 @@ CODE_SAMPLE
$this->removeNode($node);
return $node;
}
private function shouldSkip(?\PhpParser\Node $nextNode) : bool
{
if ($nextNode === null) {
return \true;
}
return $nextNode instanceof \PhpParser\Node\Stmt\Return_ && $nextNode->expr === null;
}
/**
* @param If_[] $ifs
* @return If_[]

View File

@ -16,11 +16,11 @@ final class VersionResolver
/**
* @var string
*/
public const PACKAGE_VERSION = '654d4a2a2ba408a3143a5a11a775750b90b27866';
public const PACKAGE_VERSION = '4d60c23f7ca299b8fce8e8a71dc766dae9122e0e';
/**
* @var string
*/
public const RELEASE_DATE = '2021-08-31 19:20:06';
public const RELEASE_DATE = '2021-08-31 19:51:46';
public static function resolvePackageVersion() : string
{
$process = new \RectorPrefix20210831\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 ComposerAutoloaderInit7dc5125f070db1d4791ec92ffe204c39::getLoader();
return ComposerAutoloaderInitd73d18d2a0b16e6d16139b1955b99068::getLoader();

View File

@ -2,7 +2,7 @@
// autoload_real.php @generated by Composer
class ComposerAutoloaderInit7dc5125f070db1d4791ec92ffe204c39
class ComposerAutoloaderInitd73d18d2a0b16e6d16139b1955b99068
{
private static $loader;
@ -22,15 +22,15 @@ class ComposerAutoloaderInit7dc5125f070db1d4791ec92ffe204c39
return self::$loader;
}
spl_autoload_register(array('ComposerAutoloaderInit7dc5125f070db1d4791ec92ffe204c39', 'loadClassLoader'), true, true);
spl_autoload_register(array('ComposerAutoloaderInitd73d18d2a0b16e6d16139b1955b99068', 'loadClassLoader'), true, true);
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(\dirname(__FILE__)));
spl_autoload_unregister(array('ComposerAutoloaderInit7dc5125f070db1d4791ec92ffe204c39', 'loadClassLoader'));
spl_autoload_unregister(array('ComposerAutoloaderInitd73d18d2a0b16e6d16139b1955b99068', '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\ComposerStaticInit7dc5125f070db1d4791ec92ffe204c39::getInitializer($loader));
call_user_func(\Composer\Autoload\ComposerStaticInitd73d18d2a0b16e6d16139b1955b99068::getInitializer($loader));
} else {
$classMap = require __DIR__ . '/autoload_classmap.php';
if ($classMap) {
@ -42,19 +42,19 @@ class ComposerAutoloaderInit7dc5125f070db1d4791ec92ffe204c39
$loader->register(true);
if ($useStaticLoader) {
$includeFiles = Composer\Autoload\ComposerStaticInit7dc5125f070db1d4791ec92ffe204c39::$files;
$includeFiles = Composer\Autoload\ComposerStaticInitd73d18d2a0b16e6d16139b1955b99068::$files;
} else {
$includeFiles = require __DIR__ . '/autoload_files.php';
}
foreach ($includeFiles as $fileIdentifier => $file) {
composerRequire7dc5125f070db1d4791ec92ffe204c39($fileIdentifier, $file);
composerRequired73d18d2a0b16e6d16139b1955b99068($fileIdentifier, $file);
}
return $loader;
}
}
function composerRequire7dc5125f070db1d4791ec92ffe204c39($fileIdentifier, $file)
function composerRequired73d18d2a0b16e6d16139b1955b99068($fileIdentifier, $file)
{
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
require $file;

View File

@ -4,7 +4,7 @@
namespace Composer\Autoload;
class ComposerStaticInit7dc5125f070db1d4791ec92ffe204c39
class ComposerStaticInitd73d18d2a0b16e6d16139b1955b99068
{
public static $files = array (
'a4a119a56e50fbb293281d9a48007e0e' => __DIR__ . '/..' . '/symfony/polyfill-php80/bootstrap.php',
@ -3856,9 +3856,9 @@ class ComposerStaticInit7dc5125f070db1d4791ec92ffe204c39
public static function getInitializer(ClassLoader $loader)
{
return \Closure::bind(function () use ($loader) {
$loader->prefixLengthsPsr4 = ComposerStaticInit7dc5125f070db1d4791ec92ffe204c39::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInit7dc5125f070db1d4791ec92ffe204c39::$prefixDirsPsr4;
$loader->classMap = ComposerStaticInit7dc5125f070db1d4791ec92ffe204c39::$classMap;
$loader->prefixLengthsPsr4 = ComposerStaticInitd73d18d2a0b16e6d16139b1955b99068::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInitd73d18d2a0b16e6d16139b1955b99068::$prefixDirsPsr4;
$loader->classMap = ComposerStaticInitd73d18d2a0b16e6d16139b1955b99068::$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('RectorPrefix20210831\AutoloadIncluder');
}
if (!class_exists('ComposerAutoloaderInit7dc5125f070db1d4791ec92ffe204c39', false) && !interface_exists('ComposerAutoloaderInit7dc5125f070db1d4791ec92ffe204c39', false) && !trait_exists('ComposerAutoloaderInit7dc5125f070db1d4791ec92ffe204c39', false)) {
spl_autoload_call('RectorPrefix20210831\ComposerAutoloaderInit7dc5125f070db1d4791ec92ffe204c39');
if (!class_exists('ComposerAutoloaderInitd73d18d2a0b16e6d16139b1955b99068', false) && !interface_exists('ComposerAutoloaderInitd73d18d2a0b16e6d16139b1955b99068', false) && !trait_exists('ComposerAutoloaderInitd73d18d2a0b16e6d16139b1955b99068', false)) {
spl_autoload_call('RectorPrefix20210831\ComposerAutoloaderInitd73d18d2a0b16e6d16139b1955b99068');
}
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('RectorPrefix20210831\Helmich\TypoScriptParser\Parser\AST\Statement');
@ -3311,9 +3311,9 @@ if (!function_exists('print_node')) {
return \RectorPrefix20210831\print_node(...func_get_args());
}
}
if (!function_exists('composerRequire7dc5125f070db1d4791ec92ffe204c39')) {
function composerRequire7dc5125f070db1d4791ec92ffe204c39() {
return \RectorPrefix20210831\composerRequire7dc5125f070db1d4791ec92ffe204c39(...func_get_args());
if (!function_exists('composerRequired73d18d2a0b16e6d16139b1955b99068')) {
function composerRequired73d18d2a0b16e6d16139b1955b99068() {
return \RectorPrefix20210831\composerRequired73d18d2a0b16e6d16139b1955b99068(...func_get_args());
}
}
if (!function_exists('parseArgs')) {