mirror of
https://github.com/rectorphp/rector.git
synced 2025-03-14 20:39:43 +01:00
Updated Rector to commit 56068f8571e4b8325617fa72012e58783bd03d46
56068f8571
[EarlyReturn] Skip append variable on PreparedValueToEarlyReturnRector (#4530)
This commit is contained in:
parent
34b2975e47
commit
5aeca28e79
@ -83,12 +83,15 @@ CODE_SAMPLE
|
||||
*/
|
||||
public function refactor(Node $node)
|
||||
{
|
||||
if ($node->stmts === null) {
|
||||
return null;
|
||||
}
|
||||
/** @var BareSingleAssignIf[] $bareSingleAssignIfs */
|
||||
$bareSingleAssignIfs = [];
|
||||
$initialAssign = null;
|
||||
$initialAssignPosition = null;
|
||||
foreach ((array) $node->stmts as $key => $stmt) {
|
||||
$bareSingleAssignIf = $this->matchBareSingleAssignIf($stmt);
|
||||
foreach ($node->stmts as $key => $stmt) {
|
||||
$bareSingleAssignIf = $this->matchBareSingleAssignIf($stmt, $key, $node);
|
||||
if ($bareSingleAssignIf instanceof BareSingleAssignIf) {
|
||||
$bareSingleAssignIfs[] = $bareSingleAssignIf;
|
||||
continue;
|
||||
@ -143,7 +146,7 @@ CODE_SAMPLE
|
||||
}
|
||||
return \true;
|
||||
}
|
||||
private function matchBareSingleAssignIf(Stmt $stmt) : ?BareSingleAssignIf
|
||||
private function matchBareSingleAssignIf(Stmt $stmt, int $key, StmtsAwareInterface $stmtsAware) : ?BareSingleAssignIf
|
||||
{
|
||||
if (!$stmt instanceof If_) {
|
||||
return null;
|
||||
@ -163,7 +166,16 @@ CODE_SAMPLE
|
||||
if (!$this->ifManipulator->isIfWithoutElseAndElseIfs($stmt)) {
|
||||
return null;
|
||||
}
|
||||
return new BareSingleAssignIf($stmt, $expression->expr);
|
||||
if (!isset($stmtsAware->stmts[$key + 1])) {
|
||||
return null;
|
||||
}
|
||||
if ($stmtsAware->stmts[$key + 1] instanceof If_) {
|
||||
return new BareSingleAssignIf($stmt, $expression->expr);
|
||||
}
|
||||
if ($stmtsAware->stmts[$key + 1] instanceof Return_) {
|
||||
return new BareSingleAssignIf($stmt, $expression->expr);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
/**
|
||||
* @param BareSingleAssignIf[] $bareSingleAssignIfs
|
||||
|
@ -3,6 +3,7 @@
|
||||
declare (strict_types=1);
|
||||
namespace Rector\TypeDeclaration\TypeAnalyzer;
|
||||
|
||||
use PhpParser\Node\Expr\ClassConstFetch;
|
||||
use PhpParser\Node;
|
||||
use PhpParser\Node\Expr;
|
||||
use PhpParser\Node\Expr\Array_;
|
||||
@ -63,7 +64,7 @@ final class ReturnStrictTypeAnalyzer
|
||||
if ($returnedExpr instanceof MethodCall || $returnedExpr instanceof StaticCall || $returnedExpr instanceof FuncCall) {
|
||||
$containsStrictCall = \true;
|
||||
$returnNode = $this->resolveMethodCallReturnNode($returnedExpr);
|
||||
} elseif ($returnedExpr instanceof Expr\ClassConstFetch) {
|
||||
} elseif ($returnedExpr instanceof ClassConstFetch) {
|
||||
$returnNode = $this->resolveConstFetchReturnNode($returnedExpr, $scope);
|
||||
} elseif ($returnedExpr instanceof Array_ || $returnedExpr instanceof String_ || $returnedExpr instanceof LNumber || $returnedExpr instanceof DNumber) {
|
||||
$returnNode = $this->resolveLiteralReturnNode($returnedExpr, $scope);
|
||||
@ -109,9 +110,9 @@ final class ReturnStrictTypeAnalyzer
|
||||
$returnType = $scope->getType($returnedExpr);
|
||||
return $this->staticTypeMapper->mapPHPStanTypeToPhpParserNode($returnType, TypeKind::RETURN);
|
||||
}
|
||||
private function resolveConstFetchReturnNode(Expr\ClassConstFetch $returnedExpr, Scope $scope) : ?Node
|
||||
private function resolveConstFetchReturnNode(ClassConstFetch $classConstFetch, Scope $scope) : ?Node
|
||||
{
|
||||
$constType = $scope->getType($returnedExpr);
|
||||
$constType = $scope->getType($classConstFetch);
|
||||
if ($constType instanceof MixedType) {
|
||||
return null;
|
||||
}
|
||||
|
@ -19,12 +19,12 @@ final class VersionResolver
|
||||
* @api
|
||||
* @var string
|
||||
*/
|
||||
public const PACKAGE_VERSION = 'cebcea0a9aae472a64f80608d88e79a91797a67d';
|
||||
public const PACKAGE_VERSION = '56068f8571e4b8325617fa72012e58783bd03d46';
|
||||
/**
|
||||
* @api
|
||||
* @var string
|
||||
*/
|
||||
public const RELEASE_DATE = '2023-07-17 03:34:15';
|
||||
public const RELEASE_DATE = '2023-07-17 11:35:18';
|
||||
/**
|
||||
* @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 ComposerAutoloaderInit4c6e31259a637b78f122f17add4a627c::getLoader();
|
||||
return ComposerAutoloaderInit6fc7ebfdba45eebf190fa147a01af196::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 ComposerAutoloaderInit4c6e31259a637b78f122f17add4a627c
|
||||
class ComposerAutoloaderInit6fc7ebfdba45eebf190fa147a01af196
|
||||
{
|
||||
private static $loader;
|
||||
|
||||
@ -22,17 +22,17 @@ class ComposerAutoloaderInit4c6e31259a637b78f122f17add4a627c
|
||||
return self::$loader;
|
||||
}
|
||||
|
||||
spl_autoload_register(array('ComposerAutoloaderInit4c6e31259a637b78f122f17add4a627c', 'loadClassLoader'), true, true);
|
||||
spl_autoload_register(array('ComposerAutoloaderInit6fc7ebfdba45eebf190fa147a01af196', 'loadClassLoader'), true, true);
|
||||
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__));
|
||||
spl_autoload_unregister(array('ComposerAutoloaderInit4c6e31259a637b78f122f17add4a627c', 'loadClassLoader'));
|
||||
spl_autoload_unregister(array('ComposerAutoloaderInit6fc7ebfdba45eebf190fa147a01af196', 'loadClassLoader'));
|
||||
|
||||
require __DIR__ . '/autoload_static.php';
|
||||
call_user_func(\Composer\Autoload\ComposerStaticInit4c6e31259a637b78f122f17add4a627c::getInitializer($loader));
|
||||
call_user_func(\Composer\Autoload\ComposerStaticInit6fc7ebfdba45eebf190fa147a01af196::getInitializer($loader));
|
||||
|
||||
$loader->setClassMapAuthoritative(true);
|
||||
$loader->register(true);
|
||||
|
||||
$filesToLoad = \Composer\Autoload\ComposerStaticInit4c6e31259a637b78f122f17add4a627c::$files;
|
||||
$filesToLoad = \Composer\Autoload\ComposerStaticInit6fc7ebfdba45eebf190fa147a01af196::$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 ComposerStaticInit4c6e31259a637b78f122f17add4a627c
|
||||
class ComposerStaticInit6fc7ebfdba45eebf190fa147a01af196
|
||||
{
|
||||
public static $files = array (
|
||||
'ad155f8f1cf0d418fe49e248db8c661b' => __DIR__ . '/..' . '/react/promise/src/functions_include.php',
|
||||
@ -3028,9 +3028,9 @@ class ComposerStaticInit4c6e31259a637b78f122f17add4a627c
|
||||
public static function getInitializer(ClassLoader $loader)
|
||||
{
|
||||
return \Closure::bind(function () use ($loader) {
|
||||
$loader->prefixLengthsPsr4 = ComposerStaticInit4c6e31259a637b78f122f17add4a627c::$prefixLengthsPsr4;
|
||||
$loader->prefixDirsPsr4 = ComposerStaticInit4c6e31259a637b78f122f17add4a627c::$prefixDirsPsr4;
|
||||
$loader->classMap = ComposerStaticInit4c6e31259a637b78f122f17add4a627c::$classMap;
|
||||
$loader->prefixLengthsPsr4 = ComposerStaticInit6fc7ebfdba45eebf190fa147a01af196::$prefixLengthsPsr4;
|
||||
$loader->prefixDirsPsr4 = ComposerStaticInit6fc7ebfdba45eebf190fa147a01af196::$prefixDirsPsr4;
|
||||
$loader->classMap = ComposerStaticInit6fc7ebfdba45eebf190fa147a01af196::$classMap;
|
||||
|
||||
}, null, ClassLoader::class);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user