mirror of
https://github.com/rectorphp/rector.git
synced 2025-01-17 21:38:22 +01:00
Updated Rector to commit 2d174631c410c5ec1767a28905206e2e678b546b
2d174631c4
[CodeQuality] Handle return new object and no return on ConsecutiveNullCompareReturnsToNullCoalesceQueueRector (#4112)
This commit is contained in:
parent
1d6fa53888
commit
4e35c1eafd
@ -87,6 +87,9 @@ CODE_SAMPLE
|
||||
if (!$comparedExpr instanceof Expr) {
|
||||
continue;
|
||||
}
|
||||
if (!isset($node->stmts[$key + 1])) {
|
||||
return null;
|
||||
}
|
||||
$coalescingExprs[] = $comparedExpr;
|
||||
$ifKeys[] = $key;
|
||||
}
|
||||
@ -95,8 +98,9 @@ CODE_SAMPLE
|
||||
return null;
|
||||
}
|
||||
// remove last return null
|
||||
$throwExpr = null;
|
||||
$appendExpr = null;
|
||||
$hasChanged = \false;
|
||||
$originalStmts = $node->stmts;
|
||||
foreach ($node->stmts as $key => $stmt) {
|
||||
if (\in_array($key, $ifKeys, \true)) {
|
||||
unset($node->stmts[$key]);
|
||||
@ -108,15 +112,21 @@ CODE_SAMPLE
|
||||
}
|
||||
if ($stmt instanceof Throw_) {
|
||||
unset($node->stmts[$key]);
|
||||
$throwExpr = new ExprThrow_($stmt->expr);
|
||||
$appendExpr = new ExprThrow_($stmt->expr);
|
||||
continue;
|
||||
}
|
||||
if (!$this->isReturnNull($stmt)) {
|
||||
continue;
|
||||
if ($stmt instanceof Return_ && $stmt->expr instanceof Expr) {
|
||||
unset($node->stmts[$key]);
|
||||
$appendExpr = $stmt->expr;
|
||||
continue;
|
||||
}
|
||||
$node->stmts = $originalStmts;
|
||||
return $node;
|
||||
}
|
||||
unset($node->stmts[$key]);
|
||||
}
|
||||
$node->stmts[] = $this->createCealesceReturn($coalescingExprs, $throwExpr);
|
||||
$node->stmts[] = $this->createCealesceReturn($coalescingExprs, $appendExpr);
|
||||
return $node;
|
||||
}
|
||||
public function provideMinPhpVersion() : int
|
||||
@ -136,7 +146,7 @@ CODE_SAMPLE
|
||||
/**
|
||||
* @param Expr[] $coalescingExprs
|
||||
*/
|
||||
private function createCealesceReturn(array $coalescingExprs, ?Expr $throwExpr) : Return_
|
||||
private function createCealesceReturn(array $coalescingExprs, ?Expr $appendExpr) : Return_
|
||||
{
|
||||
/** @var Expr $leftExpr */
|
||||
$leftExpr = \array_shift($coalescingExprs);
|
||||
@ -146,8 +156,8 @@ CODE_SAMPLE
|
||||
foreach ($coalescingExprs as $coalescingExpr) {
|
||||
$coalesce = new Coalesce($coalesce, $coalescingExpr);
|
||||
}
|
||||
if ($throwExpr instanceof Expr) {
|
||||
return new Return_(new Coalesce($coalesce, $throwExpr));
|
||||
if ($appendExpr instanceof Expr) {
|
||||
return new Return_(new Coalesce($coalesce, $appendExpr));
|
||||
}
|
||||
return new Return_($coalesce);
|
||||
}
|
||||
|
@ -19,12 +19,12 @@ final class VersionResolver
|
||||
* @api
|
||||
* @var string
|
||||
*/
|
||||
public const PACKAGE_VERSION = '7f73d653b9ceb059f9d05e010a7c6120f23c77ac';
|
||||
public const PACKAGE_VERSION = '2d174631c410c5ec1767a28905206e2e678b546b';
|
||||
/**
|
||||
* @api
|
||||
* @var string
|
||||
*/
|
||||
public const RELEASE_DATE = '2023-06-08 09:04:34';
|
||||
public const RELEASE_DATE = '2023-06-08 10:03:51';
|
||||
/**
|
||||
* @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 ComposerAutoloaderInit14157378de742e5984eef7e43b2391aa::getLoader();
|
||||
return ComposerAutoloaderInit153c77e4f691c76307309b78b5f1a5c1::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 ComposerAutoloaderInit14157378de742e5984eef7e43b2391aa
|
||||
class ComposerAutoloaderInit153c77e4f691c76307309b78b5f1a5c1
|
||||
{
|
||||
private static $loader;
|
||||
|
||||
@ -22,17 +22,17 @@ class ComposerAutoloaderInit14157378de742e5984eef7e43b2391aa
|
||||
return self::$loader;
|
||||
}
|
||||
|
||||
spl_autoload_register(array('ComposerAutoloaderInit14157378de742e5984eef7e43b2391aa', 'loadClassLoader'), true, true);
|
||||
spl_autoload_register(array('ComposerAutoloaderInit153c77e4f691c76307309b78b5f1a5c1', 'loadClassLoader'), true, true);
|
||||
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__));
|
||||
spl_autoload_unregister(array('ComposerAutoloaderInit14157378de742e5984eef7e43b2391aa', 'loadClassLoader'));
|
||||
spl_autoload_unregister(array('ComposerAutoloaderInit153c77e4f691c76307309b78b5f1a5c1', 'loadClassLoader'));
|
||||
|
||||
require __DIR__ . '/autoload_static.php';
|
||||
call_user_func(\Composer\Autoload\ComposerStaticInit14157378de742e5984eef7e43b2391aa::getInitializer($loader));
|
||||
call_user_func(\Composer\Autoload\ComposerStaticInit153c77e4f691c76307309b78b5f1a5c1::getInitializer($loader));
|
||||
|
||||
$loader->setClassMapAuthoritative(true);
|
||||
$loader->register(true);
|
||||
|
||||
$filesToLoad = \Composer\Autoload\ComposerStaticInit14157378de742e5984eef7e43b2391aa::$files;
|
||||
$filesToLoad = \Composer\Autoload\ComposerStaticInit153c77e4f691c76307309b78b5f1a5c1::$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 ComposerStaticInit14157378de742e5984eef7e43b2391aa
|
||||
class ComposerStaticInit153c77e4f691c76307309b78b5f1a5c1
|
||||
{
|
||||
public static $files = array (
|
||||
'ad155f8f1cf0d418fe49e248db8c661b' => __DIR__ . '/..' . '/react/promise/src/functions_include.php',
|
||||
@ -3031,9 +3031,9 @@ class ComposerStaticInit14157378de742e5984eef7e43b2391aa
|
||||
public static function getInitializer(ClassLoader $loader)
|
||||
{
|
||||
return \Closure::bind(function () use ($loader) {
|
||||
$loader->prefixLengthsPsr4 = ComposerStaticInit14157378de742e5984eef7e43b2391aa::$prefixLengthsPsr4;
|
||||
$loader->prefixDirsPsr4 = ComposerStaticInit14157378de742e5984eef7e43b2391aa::$prefixDirsPsr4;
|
||||
$loader->classMap = ComposerStaticInit14157378de742e5984eef7e43b2391aa::$classMap;
|
||||
$loader->prefixLengthsPsr4 = ComposerStaticInit153c77e4f691c76307309b78b5f1a5c1::$prefixLengthsPsr4;
|
||||
$loader->prefixDirsPsr4 = ComposerStaticInit153c77e4f691c76307309b78b5f1a5c1::$prefixDirsPsr4;
|
||||
$loader->classMap = ComposerStaticInit153c77e4f691c76307309b78b5f1a5c1::$classMap;
|
||||
|
||||
}, null, ClassLoader::class);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user