Updated Rector to commit 66a9bcff33fce09aff972693263c04cc4cdd3604

66a9bcff33 [EarlyReturn] Remove findFirstNext() on InvertedIfFactory (#4399)
This commit is contained in:
Tomas Votruba 2023-07-01 17:58:08 +00:00
parent b083f2427f
commit d403caf40e
5 changed files with 15 additions and 30 deletions

View File

@ -3,23 +3,16 @@
declare (strict_types=1);
namespace Rector\EarlyReturn\NodeFactory;
use PhpParser\Node;
use PhpParser\Node\Expr;
use PhpParser\Node\Stmt;
use PhpParser\Node\Stmt\Continue_;
use PhpParser\Node\Stmt\If_;
use PhpParser\Node\Stmt\Return_;
use Rector\Core\PhpParser\Node\BetterNodeFinder;
use Rector\EarlyReturn\NodeTransformer\ConditionInverter;
use Rector\NodeNestingScope\ContextAnalyzer;
use Rector\NodeTypeResolver\Node\AttributeKey;
final class InvertedIfFactory
{
/**
* @readonly
* @var \Rector\Core\PhpParser\Node\BetterNodeFinder
*/
private $betterNodeFinder;
/**
* @readonly
* @var \Rector\EarlyReturn\NodeTransformer\ConditionInverter
@ -30,9 +23,8 @@ final class InvertedIfFactory
* @var \Rector\NodeNestingScope\ContextAnalyzer
*/
private $contextAnalyzer;
public function __construct(BetterNodeFinder $betterNodeFinder, ConditionInverter $conditionInverter, ContextAnalyzer $contextAnalyzer)
public function __construct(ConditionInverter $conditionInverter, ContextAnalyzer $contextAnalyzer)
{
$this->betterNodeFinder = $betterNodeFinder;
$this->conditionInverter = $conditionInverter;
$this->contextAnalyzer = $contextAnalyzer;
}
@ -47,9 +39,8 @@ final class InvertedIfFactory
if ($ifNextReturn instanceof Return_) {
$stmt[0]->setAttribute(AttributeKey::COMMENTS, $ifNextReturn->getAttribute(AttributeKey::COMMENTS));
}
$getNextReturnExpr = $this->getNextReturnExpr($if);
if ($getNextReturnExpr instanceof Return_) {
$return->expr = $getNextReturnExpr->expr;
if ($ifNextReturn instanceof Return_ && $ifNextReturn->expr instanceof Expr) {
$return->expr = $ifNextReturn->expr;
}
foreach ($conditions as $condition) {
$invertedCondition = $this->conditionInverter->createInvertedCondition($condition);
@ -59,10 +50,4 @@ final class InvertedIfFactory
}
return $ifs;
}
private function getNextReturnExpr(If_ $if) : ?Node
{
return $this->betterNodeFinder->findFirstNext($if, static function (Node $node) : bool {
return $node instanceof Return_ && $node->expr instanceof Expr;
});
}
}

View File

@ -19,12 +19,12 @@ final class VersionResolver
* @api
* @var string
*/
public const PACKAGE_VERSION = '6e90cc741ca2e6d94fe485fd01c085a7641d5d93';
public const PACKAGE_VERSION = '66a9bcff33fce09aff972693263c04cc4cdd3604';
/**
* @api
* @var string
*/
public const RELEASE_DATE = '2023-07-01 22:45:25';
public const RELEASE_DATE = '2023-07-02 00:54:02';
/**
* @var int
*/

2
vendor/autoload.php vendored
View File

@ -22,4 +22,4 @@ if (PHP_VERSION_ID < 50600) {
require_once __DIR__ . '/composer/autoload_real.php';
return ComposerAutoloaderInit60fb7a85feaf5cd9d65eff709f631b40::getLoader();
return ComposerAutoloaderInit845601d9011761092cd205b9eee13f56::getLoader();

View File

@ -2,7 +2,7 @@
// autoload_real.php @generated by Composer
class ComposerAutoloaderInit60fb7a85feaf5cd9d65eff709f631b40
class ComposerAutoloaderInit845601d9011761092cd205b9eee13f56
{
private static $loader;
@ -22,17 +22,17 @@ class ComposerAutoloaderInit60fb7a85feaf5cd9d65eff709f631b40
return self::$loader;
}
spl_autoload_register(array('ComposerAutoloaderInit60fb7a85feaf5cd9d65eff709f631b40', 'loadClassLoader'), true, true);
spl_autoload_register(array('ComposerAutoloaderInit845601d9011761092cd205b9eee13f56', 'loadClassLoader'), true, true);
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__));
spl_autoload_unregister(array('ComposerAutoloaderInit60fb7a85feaf5cd9d65eff709f631b40', 'loadClassLoader'));
spl_autoload_unregister(array('ComposerAutoloaderInit845601d9011761092cd205b9eee13f56', 'loadClassLoader'));
require __DIR__ . '/autoload_static.php';
call_user_func(\Composer\Autoload\ComposerStaticInit60fb7a85feaf5cd9d65eff709f631b40::getInitializer($loader));
call_user_func(\Composer\Autoload\ComposerStaticInit845601d9011761092cd205b9eee13f56::getInitializer($loader));
$loader->setClassMapAuthoritative(true);
$loader->register(true);
$filesToLoad = \Composer\Autoload\ComposerStaticInit60fb7a85feaf5cd9d65eff709f631b40::$files;
$filesToLoad = \Composer\Autoload\ComposerStaticInit845601d9011761092cd205b9eee13f56::$files;
$requireFile = \Closure::bind(static function ($fileIdentifier, $file) {
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
$GLOBALS['__composer_autoload_files'][$fileIdentifier] = true;

View File

@ -4,7 +4,7 @@
namespace Composer\Autoload;
class ComposerStaticInit60fb7a85feaf5cd9d65eff709f631b40
class ComposerStaticInit845601d9011761092cd205b9eee13f56
{
public static $files = array (
'ad155f8f1cf0d418fe49e248db8c661b' => __DIR__ . '/..' . '/react/promise/src/functions_include.php',
@ -3099,9 +3099,9 @@ class ComposerStaticInit60fb7a85feaf5cd9d65eff709f631b40
public static function getInitializer(ClassLoader $loader)
{
return \Closure::bind(function () use ($loader) {
$loader->prefixLengthsPsr4 = ComposerStaticInit60fb7a85feaf5cd9d65eff709f631b40::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInit60fb7a85feaf5cd9d65eff709f631b40::$prefixDirsPsr4;
$loader->classMap = ComposerStaticInit60fb7a85feaf5cd9d65eff709f631b40::$classMap;
$loader->prefixLengthsPsr4 = ComposerStaticInit845601d9011761092cd205b9eee13f56::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInit845601d9011761092cd205b9eee13f56::$prefixDirsPsr4;
$loader->classMap = ComposerStaticInit845601d9011761092cd205b9eee13f56::$classMap;
}, null, ClassLoader::class);
}