mirror of
https://github.com/rectorphp/rector.git
synced 2025-01-17 21:38:22 +01:00
Updated Rector to commit 3d07c26d3efc4c0c16cbbe1fb347114e0178cc5e
3d07c26d3e
[Php70] Remove parent lookup for Break_ inside Switch_ on BreakNotInLoopOrSwitchToReturnRector (#4269)
This commit is contained in:
parent
950bd50ad1
commit
a80b7eaeaf
@ -7,7 +7,6 @@ use PhpParser\Node;
|
||||
use PhpParser\Node\FunctionLike;
|
||||
use PhpParser\Node\Stmt\ClassMethod;
|
||||
use PhpParser\Node\Stmt\If_;
|
||||
use PhpParser\Node\Stmt\Switch_;
|
||||
use Rector\Core\PhpParser\Node\BetterNodeFinder;
|
||||
use Rector\NodeNestingScope\ValueObject\ControlStructure;
|
||||
final class ContextAnalyzer
|
||||
@ -39,13 +38,6 @@ final class ContextAnalyzer
|
||||
}
|
||||
return \false;
|
||||
}
|
||||
/**
|
||||
* @api
|
||||
*/
|
||||
public function isInSwitch(Node $node) : bool
|
||||
{
|
||||
return (bool) $this->betterNodeFinder->findParentType($node, Switch_::class);
|
||||
}
|
||||
/**
|
||||
* @api
|
||||
*/
|
||||
|
@ -6,6 +6,7 @@ namespace Rector\Php70\Rector\Break_;
|
||||
use PhpParser\Node;
|
||||
use PhpParser\Node\Stmt\Break_;
|
||||
use PhpParser\Node\Stmt\Return_;
|
||||
use PhpParser\Node\Stmt\Switch_;
|
||||
use PhpParser\NodeTraverser;
|
||||
use Rector\Core\Rector\AbstractRector;
|
||||
use Rector\Core\ValueObject\PhpVersionFeature;
|
||||
@ -26,6 +27,10 @@ final class BreakNotInLoopOrSwitchToReturnRector extends AbstractRector implemen
|
||||
* @var \Rector\NodeNestingScope\ContextAnalyzer
|
||||
*/
|
||||
private $contextAnalyzer;
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private const IS_BREAK_IN_SWITCH = 'is_break_in_switch';
|
||||
public function __construct(ContextAnalyzer $contextAnalyzer)
|
||||
{
|
||||
$this->contextAnalyzer = $contextAnalyzer;
|
||||
@ -69,18 +74,28 @@ CODE_SAMPLE
|
||||
*/
|
||||
public function getNodeTypes() : array
|
||||
{
|
||||
return [Break_::class];
|
||||
return [Switch_::class, Break_::class];
|
||||
}
|
||||
/**
|
||||
* @param Break_ $node
|
||||
* @param Switch_|Break_ $node
|
||||
* @return \PhpParser\Node\Stmt\Return_|null|int
|
||||
*/
|
||||
public function refactor(Node $node)
|
||||
{
|
||||
if ($node instanceof Switch_) {
|
||||
$this->traverseNodesWithCallable($node->cases, static function (Node $subNode) {
|
||||
if (!$subNode instanceof Break_) {
|
||||
return null;
|
||||
}
|
||||
$subNode->setAttribute(self::IS_BREAK_IN_SWITCH, \true);
|
||||
return null;
|
||||
});
|
||||
return null;
|
||||
}
|
||||
if ($this->contextAnalyzer->isInLoop($node)) {
|
||||
return null;
|
||||
}
|
||||
if ($this->contextAnalyzer->isInSwitch($node)) {
|
||||
if ($node->getAttribute(self::IS_BREAK_IN_SWITCH) === \true) {
|
||||
return null;
|
||||
}
|
||||
if ($this->contextAnalyzer->isInIf($node)) {
|
||||
|
@ -19,12 +19,12 @@ final class VersionResolver
|
||||
* @api
|
||||
* @var string
|
||||
*/
|
||||
public const PACKAGE_VERSION = '392898c5de7e25ceeb83072eb951939ddf1c7150';
|
||||
public const PACKAGE_VERSION = '3d07c26d3efc4c0c16cbbe1fb347114e0178cc5e';
|
||||
/**
|
||||
* @api
|
||||
* @var string
|
||||
*/
|
||||
public const RELEASE_DATE = '2023-06-18 10:45:19';
|
||||
public const RELEASE_DATE = '2023-06-18 05:17:36';
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
|
2
vendor/autoload.php
vendored
2
vendor/autoload.php
vendored
@ -22,4 +22,4 @@ if (PHP_VERSION_ID < 50600) {
|
||||
|
||||
require_once __DIR__ . '/composer/autoload_real.php';
|
||||
|
||||
return ComposerAutoloaderInit3828b21a5ac14b5b6ae0465dfb4554e3::getLoader();
|
||||
return ComposerAutoloaderInit1ad8de2918e609488bd217ece42ce5c0::getLoader();
|
||||
|
10
vendor/composer/autoload_real.php
vendored
10
vendor/composer/autoload_real.php
vendored
@ -2,7 +2,7 @@
|
||||
|
||||
// autoload_real.php @generated by Composer
|
||||
|
||||
class ComposerAutoloaderInit3828b21a5ac14b5b6ae0465dfb4554e3
|
||||
class ComposerAutoloaderInit1ad8de2918e609488bd217ece42ce5c0
|
||||
{
|
||||
private static $loader;
|
||||
|
||||
@ -22,17 +22,17 @@ class ComposerAutoloaderInit3828b21a5ac14b5b6ae0465dfb4554e3
|
||||
return self::$loader;
|
||||
}
|
||||
|
||||
spl_autoload_register(array('ComposerAutoloaderInit3828b21a5ac14b5b6ae0465dfb4554e3', 'loadClassLoader'), true, true);
|
||||
spl_autoload_register(array('ComposerAutoloaderInit1ad8de2918e609488bd217ece42ce5c0', 'loadClassLoader'), true, true);
|
||||
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__));
|
||||
spl_autoload_unregister(array('ComposerAutoloaderInit3828b21a5ac14b5b6ae0465dfb4554e3', 'loadClassLoader'));
|
||||
spl_autoload_unregister(array('ComposerAutoloaderInit1ad8de2918e609488bd217ece42ce5c0', 'loadClassLoader'));
|
||||
|
||||
require __DIR__ . '/autoload_static.php';
|
||||
call_user_func(\Composer\Autoload\ComposerStaticInit3828b21a5ac14b5b6ae0465dfb4554e3::getInitializer($loader));
|
||||
call_user_func(\Composer\Autoload\ComposerStaticInit1ad8de2918e609488bd217ece42ce5c0::getInitializer($loader));
|
||||
|
||||
$loader->setClassMapAuthoritative(true);
|
||||
$loader->register(true);
|
||||
|
||||
$filesToLoad = \Composer\Autoload\ComposerStaticInit3828b21a5ac14b5b6ae0465dfb4554e3::$files;
|
||||
$filesToLoad = \Composer\Autoload\ComposerStaticInit1ad8de2918e609488bd217ece42ce5c0::$files;
|
||||
$requireFile = \Closure::bind(static function ($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 ComposerStaticInit3828b21a5ac14b5b6ae0465dfb4554e3
|
||||
class ComposerStaticInit1ad8de2918e609488bd217ece42ce5c0
|
||||
{
|
||||
public static $files = array (
|
||||
'ad155f8f1cf0d418fe49e248db8c661b' => __DIR__ . '/..' . '/react/promise/src/functions_include.php',
|
||||
@ -3094,9 +3094,9 @@ class ComposerStaticInit3828b21a5ac14b5b6ae0465dfb4554e3
|
||||
public static function getInitializer(ClassLoader $loader)
|
||||
{
|
||||
return \Closure::bind(function () use ($loader) {
|
||||
$loader->prefixLengthsPsr4 = ComposerStaticInit3828b21a5ac14b5b6ae0465dfb4554e3::$prefixLengthsPsr4;
|
||||
$loader->prefixDirsPsr4 = ComposerStaticInit3828b21a5ac14b5b6ae0465dfb4554e3::$prefixDirsPsr4;
|
||||
$loader->classMap = ComposerStaticInit3828b21a5ac14b5b6ae0465dfb4554e3::$classMap;
|
||||
$loader->prefixLengthsPsr4 = ComposerStaticInit1ad8de2918e609488bd217ece42ce5c0::$prefixLengthsPsr4;
|
||||
$loader->prefixDirsPsr4 = ComposerStaticInit1ad8de2918e609488bd217ece42ce5c0::$prefixDirsPsr4;
|
||||
$loader->classMap = ComposerStaticInit1ad8de2918e609488bd217ece42ce5c0::$classMap;
|
||||
|
||||
}, null, ClassLoader::class);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user