mirror of
https://github.com/rectorphp/rector.git
synced 2025-01-17 21:38:22 +01:00
Updated Rector to commit 5bae1ebdcee327ac3dcf4a25175f9013af54ec3d
5bae1ebdce
trigger CI
This commit is contained in:
parent
1a69dcf241
commit
fed7beb412
@ -22,7 +22,7 @@ use Rector\PostRector\Contract\Collector\NodeCollectorInterface;
|
||||
final class NodesToAddCollector implements NodeCollectorInterface
|
||||
{
|
||||
/**
|
||||
* @var Stmt[][]
|
||||
* @var array<string, Stmt[]>
|
||||
*/
|
||||
private $nodesToAddBefore = [];
|
||||
/**
|
||||
|
@ -19,12 +19,12 @@ final class VersionResolver
|
||||
* @api
|
||||
* @var string
|
||||
*/
|
||||
public const PACKAGE_VERSION = 'd413dc15e6cbe5ac10f5fe6fd06711fcb7267a0b';
|
||||
public const PACKAGE_VERSION = '5bae1ebdcee327ac3dcf4a25175f9013af54ec3d';
|
||||
/**
|
||||
* @api
|
||||
* @var string
|
||||
*/
|
||||
public const RELEASE_DATE = '2023-05-30 09:02:00';
|
||||
public const RELEASE_DATE = '2023-05-30 12:29:26';
|
||||
/**
|
||||
* @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 ComposerAutoloaderInitceef2c87734a56028d9cf95d3642be3b::getLoader();
|
||||
return ComposerAutoloaderInit6360d2ddab46ca3a5bfdee041076ce29::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 ComposerAutoloaderInitceef2c87734a56028d9cf95d3642be3b
|
||||
class ComposerAutoloaderInit6360d2ddab46ca3a5bfdee041076ce29
|
||||
{
|
||||
private static $loader;
|
||||
|
||||
@ -22,17 +22,17 @@ class ComposerAutoloaderInitceef2c87734a56028d9cf95d3642be3b
|
||||
return self::$loader;
|
||||
}
|
||||
|
||||
spl_autoload_register(array('ComposerAutoloaderInitceef2c87734a56028d9cf95d3642be3b', 'loadClassLoader'), true, true);
|
||||
spl_autoload_register(array('ComposerAutoloaderInit6360d2ddab46ca3a5bfdee041076ce29', 'loadClassLoader'), true, true);
|
||||
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__));
|
||||
spl_autoload_unregister(array('ComposerAutoloaderInitceef2c87734a56028d9cf95d3642be3b', 'loadClassLoader'));
|
||||
spl_autoload_unregister(array('ComposerAutoloaderInit6360d2ddab46ca3a5bfdee041076ce29', 'loadClassLoader'));
|
||||
|
||||
require __DIR__ . '/autoload_static.php';
|
||||
call_user_func(\Composer\Autoload\ComposerStaticInitceef2c87734a56028d9cf95d3642be3b::getInitializer($loader));
|
||||
call_user_func(\Composer\Autoload\ComposerStaticInit6360d2ddab46ca3a5bfdee041076ce29::getInitializer($loader));
|
||||
|
||||
$loader->setClassMapAuthoritative(true);
|
||||
$loader->register(true);
|
||||
|
||||
$filesToLoad = \Composer\Autoload\ComposerStaticInitceef2c87734a56028d9cf95d3642be3b::$files;
|
||||
$filesToLoad = \Composer\Autoload\ComposerStaticInit6360d2ddab46ca3a5bfdee041076ce29::$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 ComposerStaticInitceef2c87734a56028d9cf95d3642be3b
|
||||
class ComposerStaticInit6360d2ddab46ca3a5bfdee041076ce29
|
||||
{
|
||||
public static $files = array (
|
||||
'ad155f8f1cf0d418fe49e248db8c661b' => __DIR__ . '/..' . '/react/promise/src/functions_include.php',
|
||||
@ -3085,9 +3085,9 @@ class ComposerStaticInitceef2c87734a56028d9cf95d3642be3b
|
||||
public static function getInitializer(ClassLoader $loader)
|
||||
{
|
||||
return \Closure::bind(function () use ($loader) {
|
||||
$loader->prefixLengthsPsr4 = ComposerStaticInitceef2c87734a56028d9cf95d3642be3b::$prefixLengthsPsr4;
|
||||
$loader->prefixDirsPsr4 = ComposerStaticInitceef2c87734a56028d9cf95d3642be3b::$prefixDirsPsr4;
|
||||
$loader->classMap = ComposerStaticInitceef2c87734a56028d9cf95d3642be3b::$classMap;
|
||||
$loader->prefixLengthsPsr4 = ComposerStaticInit6360d2ddab46ca3a5bfdee041076ce29::$prefixLengthsPsr4;
|
||||
$loader->prefixDirsPsr4 = ComposerStaticInit6360d2ddab46ca3a5bfdee041076ce29::$prefixDirsPsr4;
|
||||
$loader->classMap = ComposerStaticInit6360d2ddab46ca3a5bfdee041076ce29::$classMap;
|
||||
|
||||
}, null, ClassLoader::class);
|
||||
}
|
||||
|
8
vendor/composer/installed.json
vendored
8
vendor/composer/installed.json
vendored
@ -1920,12 +1920,12 @@
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https:\/\/github.com\/rectorphp\/rector-downgrade-php.git",
|
||||
"reference": "f8e89a2e71a47843a5d98f8f19a4c757ae31e78f"
|
||||
"reference": "150dee55ead1c6f29d2718ce6d5b0c07bb88ae31"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https:\/\/api.github.com\/repos\/rectorphp\/rector-downgrade-php\/zipball\/f8e89a2e71a47843a5d98f8f19a4c757ae31e78f",
|
||||
"reference": "f8e89a2e71a47843a5d98f8f19a4c757ae31e78f",
|
||||
"url": "https:\/\/api.github.com\/repos\/rectorphp\/rector-downgrade-php\/zipball\/150dee55ead1c6f29d2718ce6d5b0c07bb88ae31",
|
||||
"reference": "150dee55ead1c6f29d2718ce6d5b0c07bb88ae31",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@ -1949,7 +1949,7 @@
|
||||
"tomasvotruba\/type-coverage": "^0.0.9",
|
||||
"tomasvotruba\/unused-public": "^0.0.34"
|
||||
},
|
||||
"time": "2023-05-30T09:13:34+00:00",
|
||||
"time": "2023-05-30T10:27:45+00:00",
|
||||
"default-branch": true,
|
||||
"type": "rector-extension",
|
||||
"extra": {
|
||||
|
2
vendor/composer/installed.php
vendored
2
vendor/composer/installed.php
vendored
File diff suppressed because one or more lines are too long
@ -9,7 +9,7 @@ namespace Rector\RectorInstaller;
|
||||
*/
|
||||
final class GeneratedConfig
|
||||
{
|
||||
public const EXTENSIONS = array('rector/rector-doctrine' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-doctrine', 'relative_install_path' => '../../rector-doctrine', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main 7f0656f'), 'rector/rector-downgrade-php' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-downgrade-php', 'relative_install_path' => '../../rector-downgrade-php', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main f8e89a2'), 'rector/rector-phpunit' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-phpunit', 'relative_install_path' => '../../rector-phpunit', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main e276dee'), 'rector/rector-symfony' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-symfony', 'relative_install_path' => '../../rector-symfony', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main 2348d4f'));
|
||||
public const EXTENSIONS = array('rector/rector-doctrine' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-doctrine', 'relative_install_path' => '../../rector-doctrine', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main 7f0656f'), 'rector/rector-downgrade-php' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-downgrade-php', 'relative_install_path' => '../../rector-downgrade-php', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main 150dee5'), 'rector/rector-phpunit' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-phpunit', 'relative_install_path' => '../../rector-phpunit', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main e276dee'), 'rector/rector-symfony' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-symfony', 'relative_install_path' => '../../rector-symfony', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main 2348d4f'));
|
||||
private function __construct()
|
||||
{
|
||||
}
|
||||
|
@ -81,22 +81,33 @@ CODE_SAMPLE
|
||||
*/
|
||||
public function refactor(Node $node)
|
||||
{
|
||||
$scopeStmt = $node instanceof If_ || $node instanceof ElseIf_ || $node instanceof Else_ ? $node->stmts : $node;
|
||||
if ($node instanceof If_ || $node instanceof ElseIf_) {
|
||||
$item1Unpacked = $node->stmts;
|
||||
$scopeStmt = \array_merge([$node->cond], $item1Unpacked);
|
||||
} elseif ($node instanceof Else_) {
|
||||
$scopeStmt = $node->stmts;
|
||||
} else {
|
||||
$scopeStmt = $node;
|
||||
}
|
||||
$isPartOfCond = \false;
|
||||
if ($node instanceof If_ || $node instanceof ElseIf_) {
|
||||
$isPartOfCond = $this->stmtMatcher->matchFuncCallNamed([$node->cond], 'array_key_first') || $this->stmtMatcher->matchFuncCallNamed([$node->cond], 'array_key_last');
|
||||
}
|
||||
$funcCall = $this->stmtMatcher->matchFuncCallNamed($scopeStmt, 'array_key_first');
|
||||
if ($funcCall instanceof FuncCall) {
|
||||
return $this->refactorArrayKeyFirst($funcCall, $node);
|
||||
return $this->refactorArrayKeyFirst($funcCall, $node, $isPartOfCond);
|
||||
}
|
||||
$funcCall = $this->stmtMatcher->matchFuncCallNamed($scopeStmt, 'array_key_last');
|
||||
if ($funcCall instanceof FuncCall) {
|
||||
return $this->refactorArrayKeyLast($funcCall, $node);
|
||||
return $this->refactorArrayKeyLast($funcCall, $node, $isPartOfCond);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
/**
|
||||
* @return Stmt[]|null
|
||||
* @return Stmt[]|StmtsAwareInterface|null
|
||||
* @param \PhpParser\Node\Stmt\Expression|\Rector\Core\Contract\PhpParser\Node\StmtsAwareInterface $stmt
|
||||
*/
|
||||
private function refactorArrayKeyFirst(FuncCall $funcCall, $stmt) : ?array
|
||||
private function refactorArrayKeyFirst(FuncCall $funcCall, $stmt, bool $isPartOfCond)
|
||||
{
|
||||
if (!isset($funcCall->getArgs()[0])) {
|
||||
return null;
|
||||
@ -114,7 +125,7 @@ CODE_SAMPLE
|
||||
$firstArg = $funcCall->getArgs()[0];
|
||||
$firstArg->value = $array;
|
||||
}
|
||||
if ($stmt instanceof StmtsAwareInterface) {
|
||||
if ($stmt instanceof StmtsAwareInterface && $isPartOfCond === \false) {
|
||||
$stmt->stmts = \array_merge([$resetFuncCallExpression], (array) $stmt->stmts);
|
||||
return $stmt;
|
||||
}
|
||||
@ -126,7 +137,7 @@ CODE_SAMPLE
|
||||
* @return Stmt[]|StmtsAwareInterface|null
|
||||
* @param \PhpParser\Node\Stmt\Expression|\Rector\Core\Contract\PhpParser\Node\StmtsAwareInterface $stmt
|
||||
*/
|
||||
private function refactorArrayKeyLast(FuncCall $funcCall, $stmt)
|
||||
private function refactorArrayKeyLast(FuncCall $funcCall, $stmt, bool $isPartOfCond)
|
||||
{
|
||||
$firstArg = $funcCall->getArgs()[0] ?? null;
|
||||
if (!$firstArg instanceof Arg) {
|
||||
@ -145,7 +156,7 @@ CODE_SAMPLE
|
||||
if ($originalArray !== $array) {
|
||||
$firstArg->value = $array;
|
||||
}
|
||||
if ($stmt instanceof StmtsAwareInterface) {
|
||||
if ($stmt instanceof StmtsAwareInterface && $isPartOfCond === \false) {
|
||||
$stmt->stmts = \array_merge([$endFuncCallExpression], (array) $stmt->stmts);
|
||||
return $stmt;
|
||||
}
|
||||
|
@ -3,9 +3,9 @@
|
||||
declare (strict_types=1);
|
||||
namespace Rector\NodeAnalyzer;
|
||||
|
||||
use PhpParser\Node;
|
||||
use PhpParser\Node\Expr\FuncCall;
|
||||
use PhpParser\Node\Name;
|
||||
use PhpParser\Node\Stmt;
|
||||
use Rector\Core\PhpParser\Node\BetterNodeFinder;
|
||||
final class StmtMatcher
|
||||
{
|
||||
@ -19,7 +19,7 @@ final class StmtMatcher
|
||||
$this->betterNodeFinder = $betterNodeFinder;
|
||||
}
|
||||
/**
|
||||
* @param \PhpParser\Node\Stmt|mixed[] $stmt
|
||||
* @param \PhpParser\Node|mixed[] $stmt
|
||||
*/
|
||||
public function matchFuncCallNamed($stmt, string $functionName) : ?FuncCall
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user