mirror of
https://github.com/rectorphp/rector.git
synced 2025-01-18 05:48:21 +01:00
Updated Rector to commit 0552b3a8852eb70465be2286c26071793e62fb5a
0552b3a885
[EarlyReturn] Handle continue/break in foreach with next return on ChangeAndIfToEarlyReturnRector (#946)
This commit is contained in:
parent
d102625c63
commit
93ca3f3280
@ -6,6 +6,8 @@ namespace Rector\EarlyReturn\Rector\If_;
|
||||
use PhpParser\Node;
|
||||
use PhpParser\Node\Expr;
|
||||
use PhpParser\Node\Expr\BinaryOp\BooleanAnd;
|
||||
use PhpParser\Node\Stmt\Break_;
|
||||
use PhpParser\Node\Stmt\Continue_;
|
||||
use PhpParser\Node\Stmt\Else_;
|
||||
use PhpParser\Node\Stmt\ElseIf_;
|
||||
use PhpParser\Node\Stmt\If_;
|
||||
@ -120,11 +122,21 @@ CODE_SAMPLE
|
||||
$this->removeNode($ifNextReturn);
|
||||
$afters[] = $node->stmts[0];
|
||||
$ifNextReturnClone = $node->stmts[0] instanceof \PhpParser\Node\Stmt\Return_ ? clone $node->stmts[0] : new \PhpParser\Node\Stmt\Return_();
|
||||
if ($this->contextAnalyzer->isInLoop($node)) {
|
||||
if ($this->isInLoopWithoutContinueOrBreak($node)) {
|
||||
$afters[] = new \PhpParser\Node\Stmt\Return_();
|
||||
}
|
||||
return $this->processReplaceIfs($node, $booleanAndConditions, $ifNextReturnClone, $afters);
|
||||
}
|
||||
private function isInLoopWithoutContinueOrBreak(\PhpParser\Node\Stmt\If_ $if) : bool
|
||||
{
|
||||
if (!$this->contextAnalyzer->isInLoop($if)) {
|
||||
return \false;
|
||||
}
|
||||
if ($if->stmts[0] instanceof \PhpParser\Node\Stmt\Continue_) {
|
||||
return \false;
|
||||
}
|
||||
return !$if->stmts[0] instanceof \PhpParser\Node\Stmt\Break_;
|
||||
}
|
||||
/**
|
||||
* @param Expr[] $conditions
|
||||
* @param Node[] $afters
|
||||
|
@ -16,11 +16,11 @@ final class VersionResolver
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public const PACKAGE_VERSION = '347b5938475e5b0e846be6ef631d5939a47fc1a0';
|
||||
public const PACKAGE_VERSION = '0552b3a8852eb70465be2286c26071793e62fb5a';
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public const RELEASE_DATE = '2021-10-01 15:51:01';
|
||||
public const RELEASE_DATE = '2021-10-02 00:54:47';
|
||||
public static function resolvePackageVersion() : string
|
||||
{
|
||||
$process = new \RectorPrefix20211001\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 ComposerAutoloaderInit170bfd69eb5659e25ce33963d3ba604f::getLoader();
|
||||
return ComposerAutoloaderInitd7887c7f427c584becb6df279ab74942::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 ComposerAutoloaderInit170bfd69eb5659e25ce33963d3ba604f
|
||||
class ComposerAutoloaderInitd7887c7f427c584becb6df279ab74942
|
||||
{
|
||||
private static $loader;
|
||||
|
||||
@ -22,15 +22,15 @@ class ComposerAutoloaderInit170bfd69eb5659e25ce33963d3ba604f
|
||||
return self::$loader;
|
||||
}
|
||||
|
||||
spl_autoload_register(array('ComposerAutoloaderInit170bfd69eb5659e25ce33963d3ba604f', 'loadClassLoader'), true, true);
|
||||
spl_autoload_register(array('ComposerAutoloaderInitd7887c7f427c584becb6df279ab74942', 'loadClassLoader'), true, true);
|
||||
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(\dirname(__FILE__)));
|
||||
spl_autoload_unregister(array('ComposerAutoloaderInit170bfd69eb5659e25ce33963d3ba604f', 'loadClassLoader'));
|
||||
spl_autoload_unregister(array('ComposerAutoloaderInitd7887c7f427c584becb6df279ab74942', '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\ComposerStaticInit170bfd69eb5659e25ce33963d3ba604f::getInitializer($loader));
|
||||
call_user_func(\Composer\Autoload\ComposerStaticInitd7887c7f427c584becb6df279ab74942::getInitializer($loader));
|
||||
} else {
|
||||
$classMap = require __DIR__ . '/autoload_classmap.php';
|
||||
if ($classMap) {
|
||||
@ -42,19 +42,19 @@ class ComposerAutoloaderInit170bfd69eb5659e25ce33963d3ba604f
|
||||
$loader->register(true);
|
||||
|
||||
if ($useStaticLoader) {
|
||||
$includeFiles = Composer\Autoload\ComposerStaticInit170bfd69eb5659e25ce33963d3ba604f::$files;
|
||||
$includeFiles = Composer\Autoload\ComposerStaticInitd7887c7f427c584becb6df279ab74942::$files;
|
||||
} else {
|
||||
$includeFiles = require __DIR__ . '/autoload_files.php';
|
||||
}
|
||||
foreach ($includeFiles as $fileIdentifier => $file) {
|
||||
composerRequire170bfd69eb5659e25ce33963d3ba604f($fileIdentifier, $file);
|
||||
composerRequired7887c7f427c584becb6df279ab74942($fileIdentifier, $file);
|
||||
}
|
||||
|
||||
return $loader;
|
||||
}
|
||||
}
|
||||
|
||||
function composerRequire170bfd69eb5659e25ce33963d3ba604f($fileIdentifier, $file)
|
||||
function composerRequired7887c7f427c584becb6df279ab74942($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 ComposerStaticInit170bfd69eb5659e25ce33963d3ba604f
|
||||
class ComposerStaticInitd7887c7f427c584becb6df279ab74942
|
||||
{
|
||||
public static $files = array (
|
||||
'a4a119a56e50fbb293281d9a48007e0e' => __DIR__ . '/..' . '/symfony/polyfill-php80/bootstrap.php',
|
||||
@ -3884,9 +3884,9 @@ class ComposerStaticInit170bfd69eb5659e25ce33963d3ba604f
|
||||
public static function getInitializer(ClassLoader $loader)
|
||||
{
|
||||
return \Closure::bind(function () use ($loader) {
|
||||
$loader->prefixLengthsPsr4 = ComposerStaticInit170bfd69eb5659e25ce33963d3ba604f::$prefixLengthsPsr4;
|
||||
$loader->prefixDirsPsr4 = ComposerStaticInit170bfd69eb5659e25ce33963d3ba604f::$prefixDirsPsr4;
|
||||
$loader->classMap = ComposerStaticInit170bfd69eb5659e25ce33963d3ba604f::$classMap;
|
||||
$loader->prefixLengthsPsr4 = ComposerStaticInitd7887c7f427c584becb6df279ab74942::$prefixLengthsPsr4;
|
||||
$loader->prefixDirsPsr4 = ComposerStaticInitd7887c7f427c584becb6df279ab74942::$prefixDirsPsr4;
|
||||
$loader->classMap = ComposerStaticInitd7887c7f427c584becb6df279ab74942::$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('RectorPrefix20211001\AutoloadIncluder');
|
||||
}
|
||||
if (!class_exists('ComposerAutoloaderInit170bfd69eb5659e25ce33963d3ba604f', false) && !interface_exists('ComposerAutoloaderInit170bfd69eb5659e25ce33963d3ba604f', false) && !trait_exists('ComposerAutoloaderInit170bfd69eb5659e25ce33963d3ba604f', false)) {
|
||||
spl_autoload_call('RectorPrefix20211001\ComposerAutoloaderInit170bfd69eb5659e25ce33963d3ba604f');
|
||||
if (!class_exists('ComposerAutoloaderInitd7887c7f427c584becb6df279ab74942', false) && !interface_exists('ComposerAutoloaderInitd7887c7f427c584becb6df279ab74942', false) && !trait_exists('ComposerAutoloaderInitd7887c7f427c584becb6df279ab74942', false)) {
|
||||
spl_autoload_call('RectorPrefix20211001\ComposerAutoloaderInitd7887c7f427c584becb6df279ab74942');
|
||||
}
|
||||
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('RectorPrefix20211001\Helmich\TypoScriptParser\Parser\AST\Statement');
|
||||
@ -3306,9 +3306,9 @@ if (!function_exists('print_node')) {
|
||||
return \RectorPrefix20211001\print_node(...func_get_args());
|
||||
}
|
||||
}
|
||||
if (!function_exists('composerRequire170bfd69eb5659e25ce33963d3ba604f')) {
|
||||
function composerRequire170bfd69eb5659e25ce33963d3ba604f() {
|
||||
return \RectorPrefix20211001\composerRequire170bfd69eb5659e25ce33963d3ba604f(...func_get_args());
|
||||
if (!function_exists('composerRequired7887c7f427c584becb6df279ab74942')) {
|
||||
function composerRequired7887c7f427c584becb6df279ab74942() {
|
||||
return \RectorPrefix20211001\composerRequired7887c7f427c584becb6df279ab74942(...func_get_args());
|
||||
}
|
||||
}
|
||||
if (!function_exists('parseArgs')) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user