mirror of
https://github.com/rectorphp/rector.git
synced 2024-06-15 23:52:23 +00:00
Updated Rector to commit de5c4c77a5
de5c4c77a5
[EarlyReturn] Allow usage ChangeOrIfReturnToEarlyReturnRector and RemoveAlwaysElseRector without elseif (#655)
This commit is contained in:
parent
ca101a7486
commit
40d9772df6
|
@ -67,14 +67,7 @@ CODE_SAMPLE
|
|||
if ($this->doesLastStatementBreakFlow($node)) {
|
||||
return null;
|
||||
}
|
||||
// to avoid repetitive If_ creation when used along with ChangeOrIfReturnToEarlyReturnRector
|
||||
// @see https://github.com/rectorphp/rector-src/pull/651
|
||||
if ($node->cond instanceof \PhpParser\Node\Expr\BinaryOp\BooleanOr) {
|
||||
return null;
|
||||
}
|
||||
// to avoid repetitive flipped elseif above return when used along with ChangeAndIfReturnToEarlyReturnRector
|
||||
// @see https://github.com/rectorphp/rector-src/pull/654
|
||||
if ($node->cond instanceof \PhpParser\Node\Expr\BinaryOp\BooleanAnd && \count($node->elseifs) > 1) {
|
||||
if ($this->shouldSkip($node)) {
|
||||
return null;
|
||||
}
|
||||
if ($node->elseifs !== []) {
|
||||
|
@ -105,6 +98,17 @@ CODE_SAMPLE
|
|||
}
|
||||
return null;
|
||||
}
|
||||
private function shouldSkip(\PhpParser\Node\Stmt\If_ $if) : bool
|
||||
{
|
||||
// to avoid repetitive If_ creation when used along with ChangeOrIfReturnToEarlyReturnRector
|
||||
// @see https://github.com/rectorphp/rector-src/pull/651
|
||||
if ($if->cond instanceof \PhpParser\Node\Expr\BinaryOp\BooleanOr && $if->elseifs !== []) {
|
||||
return \true;
|
||||
}
|
||||
// to avoid repetitive flipped elseif above return when used along with ChangeAndIfReturnToEarlyReturnRector
|
||||
// @see https://github.com/rectorphp/rector-src/pull/654
|
||||
return $if->cond instanceof \PhpParser\Node\Expr\BinaryOp\BooleanAnd && \count($if->elseifs) > 1;
|
||||
}
|
||||
/**
|
||||
* @return ElseIf_[]
|
||||
*/
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
declare (strict_types=1);
|
||||
namespace Rector\Php81\NodeFactory;
|
||||
|
||||
use RectorPrefix20210812\Nette\Utils\Strings;
|
||||
use PhpParser\BuilderFactory;
|
||||
use PhpParser\Node\Stmt\Class_;
|
||||
use PhpParser\Node\Stmt\ClassConst;
|
||||
|
@ -49,8 +48,8 @@ final class EnumFactory
|
|||
$shortClassName = $this->nodeNameResolver->getShortName($class);
|
||||
$enum = new \PhpParser\Node\Stmt\Enum_($shortClassName);
|
||||
// constant to cases
|
||||
$classDocInfo = $this->phpDocInfoFactory->createFromNode($class);
|
||||
$docBlockMethods = ($classDocInfo2 = $classDocInfo) ? $classDocInfo2->getTagsByName('@method') : null;
|
||||
$phpDocInfo = $this->phpDocInfoFactory->createFromNode($class);
|
||||
$docBlockMethods = ($phpDocInfo2 = $phpDocInfo) ? $phpDocInfo2->getTagsByName('@method') : null;
|
||||
if ($docBlockMethods !== null) {
|
||||
foreach ($docBlockMethods as $docBlockMethod) {
|
||||
$enum->stmts[] = $this->createEnumCaseFromDocComment($docBlockMethod);
|
||||
|
@ -67,12 +66,12 @@ final class EnumFactory
|
|||
$enumCase->setAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::COMMENTS, $classConst->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::COMMENTS));
|
||||
return $enumCase;
|
||||
}
|
||||
private function createEnumCaseFromDocComment(\PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagNode $docTagNode) : \PhpParser\Node\Stmt\EnumCase
|
||||
private function createEnumCaseFromDocComment(\PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagNode $phpDocTagNode) : \PhpParser\Node\Stmt\EnumCase
|
||||
{
|
||||
/**
|
||||
* @var MethodTagValueNode $nodeValue
|
||||
*/
|
||||
$nodeValue = $docTagNode->value;
|
||||
$nodeValue = $phpDocTagNode->value;
|
||||
return new \PhpParser\Node\Stmt\EnumCase($nodeValue->methodName, $this->builderFactory->val($nodeValue->methodName));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,11 +16,11 @@ final class VersionResolver
|
|||
/**
|
||||
* @var string
|
||||
*/
|
||||
public const PACKAGE_VERSION = '99301b3daeee68add16582b47611059fd7df540d';
|
||||
public const PACKAGE_VERSION = 'de5c4c77a5fe06ed04d1b7b97b10e29be344c734';
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public const RELEASE_DATE = '2021-08-12 17:19:05';
|
||||
public const RELEASE_DATE = '2021-08-12 15:49:40';
|
||||
public static function resolvePackageVersion() : string
|
||||
{
|
||||
$process = new \RectorPrefix20210812\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 ComposerAutoloaderInit26147bfd3b24cf86c56d0a6f4414af8f::getLoader();
|
||||
return ComposerAutoloaderInit9a82c7f010ef73380aa8ce8e34d92607::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 ComposerAutoloaderInit26147bfd3b24cf86c56d0a6f4414af8f
|
||||
class ComposerAutoloaderInit9a82c7f010ef73380aa8ce8e34d92607
|
||||
{
|
||||
private static $loader;
|
||||
|
||||
|
@ -22,15 +22,15 @@ class ComposerAutoloaderInit26147bfd3b24cf86c56d0a6f4414af8f
|
|||
return self::$loader;
|
||||
}
|
||||
|
||||
spl_autoload_register(array('ComposerAutoloaderInit26147bfd3b24cf86c56d0a6f4414af8f', 'loadClassLoader'), true, true);
|
||||
spl_autoload_register(array('ComposerAutoloaderInit9a82c7f010ef73380aa8ce8e34d92607', 'loadClassLoader'), true, true);
|
||||
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(\dirname(__FILE__)));
|
||||
spl_autoload_unregister(array('ComposerAutoloaderInit26147bfd3b24cf86c56d0a6f4414af8f', 'loadClassLoader'));
|
||||
spl_autoload_unregister(array('ComposerAutoloaderInit9a82c7f010ef73380aa8ce8e34d92607', '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\ComposerStaticInit26147bfd3b24cf86c56d0a6f4414af8f::getInitializer($loader));
|
||||
call_user_func(\Composer\Autoload\ComposerStaticInit9a82c7f010ef73380aa8ce8e34d92607::getInitializer($loader));
|
||||
} else {
|
||||
$classMap = require __DIR__ . '/autoload_classmap.php';
|
||||
if ($classMap) {
|
||||
|
@ -42,19 +42,19 @@ class ComposerAutoloaderInit26147bfd3b24cf86c56d0a6f4414af8f
|
|||
$loader->register(true);
|
||||
|
||||
if ($useStaticLoader) {
|
||||
$includeFiles = Composer\Autoload\ComposerStaticInit26147bfd3b24cf86c56d0a6f4414af8f::$files;
|
||||
$includeFiles = Composer\Autoload\ComposerStaticInit9a82c7f010ef73380aa8ce8e34d92607::$files;
|
||||
} else {
|
||||
$includeFiles = require __DIR__ . '/autoload_files.php';
|
||||
}
|
||||
foreach ($includeFiles as $fileIdentifier => $file) {
|
||||
composerRequire26147bfd3b24cf86c56d0a6f4414af8f($fileIdentifier, $file);
|
||||
composerRequire9a82c7f010ef73380aa8ce8e34d92607($fileIdentifier, $file);
|
||||
}
|
||||
|
||||
return $loader;
|
||||
}
|
||||
}
|
||||
|
||||
function composerRequire26147bfd3b24cf86c56d0a6f4414af8f($fileIdentifier, $file)
|
||||
function composerRequire9a82c7f010ef73380aa8ce8e34d92607($fileIdentifier, $file)
|
||||
{
|
||||
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
|
||||
require $file;
|
||||
|
|
8
vendor/composer/autoload_static.php
vendored
8
vendor/composer/autoload_static.php
vendored
|
@ -4,7 +4,7 @@
|
|||
|
||||
namespace Composer\Autoload;
|
||||
|
||||
class ComposerStaticInit26147bfd3b24cf86c56d0a6f4414af8f
|
||||
class ComposerStaticInit9a82c7f010ef73380aa8ce8e34d92607
|
||||
{
|
||||
public static $files = array (
|
||||
'a4a119a56e50fbb293281d9a48007e0e' => __DIR__ . '/..' . '/symfony/polyfill-php80/bootstrap.php',
|
||||
|
@ -3850,9 +3850,9 @@ class ComposerStaticInit26147bfd3b24cf86c56d0a6f4414af8f
|
|||
public static function getInitializer(ClassLoader $loader)
|
||||
{
|
||||
return \Closure::bind(function () use ($loader) {
|
||||
$loader->prefixLengthsPsr4 = ComposerStaticInit26147bfd3b24cf86c56d0a6f4414af8f::$prefixLengthsPsr4;
|
||||
$loader->prefixDirsPsr4 = ComposerStaticInit26147bfd3b24cf86c56d0a6f4414af8f::$prefixDirsPsr4;
|
||||
$loader->classMap = ComposerStaticInit26147bfd3b24cf86c56d0a6f4414af8f::$classMap;
|
||||
$loader->prefixLengthsPsr4 = ComposerStaticInit9a82c7f010ef73380aa8ce8e34d92607::$prefixLengthsPsr4;
|
||||
$loader->prefixDirsPsr4 = ComposerStaticInit9a82c7f010ef73380aa8ce8e34d92607::$prefixDirsPsr4;
|
||||
$loader->classMap = ComposerStaticInit9a82c7f010ef73380aa8ce8e34d92607::$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('RectorPrefix20210812\AutoloadIncluder');
|
||||
}
|
||||
if (!class_exists('ComposerAutoloaderInit26147bfd3b24cf86c56d0a6f4414af8f', false) && !interface_exists('ComposerAutoloaderInit26147bfd3b24cf86c56d0a6f4414af8f', false) && !trait_exists('ComposerAutoloaderInit26147bfd3b24cf86c56d0a6f4414af8f', false)) {
|
||||
spl_autoload_call('RectorPrefix20210812\ComposerAutoloaderInit26147bfd3b24cf86c56d0a6f4414af8f');
|
||||
if (!class_exists('ComposerAutoloaderInit9a82c7f010ef73380aa8ce8e34d92607', false) && !interface_exists('ComposerAutoloaderInit9a82c7f010ef73380aa8ce8e34d92607', false) && !trait_exists('ComposerAutoloaderInit9a82c7f010ef73380aa8ce8e34d92607', false)) {
|
||||
spl_autoload_call('RectorPrefix20210812\ComposerAutoloaderInit9a82c7f010ef73380aa8ce8e34d92607');
|
||||
}
|
||||
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('RectorPrefix20210812\Helmich\TypoScriptParser\Parser\AST\Statement');
|
||||
|
@ -3308,9 +3308,9 @@ if (!function_exists('print_node')) {
|
|||
return \RectorPrefix20210812\print_node(...func_get_args());
|
||||
}
|
||||
}
|
||||
if (!function_exists('composerRequire26147bfd3b24cf86c56d0a6f4414af8f')) {
|
||||
function composerRequire26147bfd3b24cf86c56d0a6f4414af8f() {
|
||||
return \RectorPrefix20210812\composerRequire26147bfd3b24cf86c56d0a6f4414af8f(...func_get_args());
|
||||
if (!function_exists('composerRequire9a82c7f010ef73380aa8ce8e34d92607')) {
|
||||
function composerRequire9a82c7f010ef73380aa8ce8e34d92607() {
|
||||
return \RectorPrefix20210812\composerRequire9a82c7f010ef73380aa8ce8e34d92607(...func_get_args());
|
||||
}
|
||||
}
|
||||
if (!function_exists('parseArgs')) {
|
||||
|
|
Loading…
Reference in New Issue
Block a user