mirror of
https://github.com/rectorphp/rector.git
synced 2024-06-19 17:42:23 +00:00
Updated Rector to commit f8e3c7b0644e4e106e18e3177bcd5eb110e9ab31
f8e3c7b064
[Php72] Remove next attribute usage on ParseStrWithResultArgumentRector (#3566)
This commit is contained in:
parent
716473919b
commit
f4c30b037a
|
@ -8,9 +8,10 @@ use PhpParser\Node\Arg;
|
|||
use PhpParser\Node\Expr\FuncCall;
|
||||
use PhpParser\Node\Expr\Variable;
|
||||
use PhpParser\Node\Stmt;
|
||||
use PhpParser\Node\Stmt\Expression;
|
||||
use Rector\Core\Contract\PhpParser\Node\StmtsAwareInterface;
|
||||
use Rector\Core\Rector\AbstractRector;
|
||||
use Rector\Core\ValueObject\PhpVersionFeature;
|
||||
use Rector\NodeTypeResolver\Node\AttributeKey;
|
||||
use Rector\VersionBonding\Contract\MinPhpVersionInterface;
|
||||
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
|
||||
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
|
||||
|
@ -42,38 +43,66 @@ CODE_SAMPLE
|
|||
*/
|
||||
public function getNodeTypes() : array
|
||||
{
|
||||
return [FuncCall::class];
|
||||
return [StmtsAwareInterface::class];
|
||||
}
|
||||
/**
|
||||
* @param FuncCall $node
|
||||
* @param StmtsAwareInterface $node
|
||||
*/
|
||||
public function refactor(Node $node) : ?Node
|
||||
public function refactor(Node $node) : ?StmtsAwareInterface
|
||||
{
|
||||
if (!$this->isName($node, 'parse_str')) {
|
||||
return $this->processStrWithResult($node, \false);
|
||||
}
|
||||
private function processStrWithResult(StmtsAwareInterface $stmtsAware, bool $hasChanged, int $jumpToKey = 0) : ?\Rector\Core\Contract\PhpParser\Node\StmtsAwareInterface
|
||||
{
|
||||
if ($stmtsAware->stmts === null) {
|
||||
return null;
|
||||
}
|
||||
if (isset($node->args[1])) {
|
||||
return null;
|
||||
\end($stmtsAware->stmts);
|
||||
$totalKeys = \key($stmtsAware->stmts);
|
||||
for ($key = $jumpToKey; $key < $totalKeys; ++$key) {
|
||||
if (!isset($stmtsAware->stmts[$key], $stmtsAware->stmts[$key + 1])) {
|
||||
break;
|
||||
}
|
||||
$stmt = $stmtsAware->stmts[$key];
|
||||
if ($this->shouldSkip($stmt)) {
|
||||
continue;
|
||||
}
|
||||
/**
|
||||
* @var Expression $stmt
|
||||
* @var FuncCall $expr
|
||||
*/
|
||||
$expr = $stmt->expr;
|
||||
$resultVariable = new Variable('result');
|
||||
$node->args[1] = new Arg($resultVariable);
|
||||
$currentStmt = $this->betterNodeFinder->resolveCurrentStatement($node);
|
||||
if (!$currentStmt instanceof Stmt) {
|
||||
return null;
|
||||
}
|
||||
$nextExpression = $currentStmt->getAttribute(AttributeKey::NEXT_NODE);
|
||||
if (!$nextExpression instanceof Node) {
|
||||
return null;
|
||||
}
|
||||
$this->traverseNodesWithCallable($nextExpression, function (Node $node) use($resultVariable) : ?Variable {
|
||||
$expr->args[1] = new Arg($resultVariable);
|
||||
$nextExpression = $stmtsAware->stmts[$key + 1];
|
||||
$this->traverseNodesWithCallable($nextExpression, function (Node $node) use($resultVariable, &$hasChanged) : ?Variable {
|
||||
if (!$node instanceof FuncCall) {
|
||||
return null;
|
||||
}
|
||||
if (!$this->isName($node, 'get_defined_vars')) {
|
||||
return null;
|
||||
}
|
||||
$hasChanged = \true;
|
||||
return $resultVariable;
|
||||
});
|
||||
return $node;
|
||||
return $this->processStrWithResult($stmtsAware, $hasChanged, $key + 2);
|
||||
}
|
||||
if ($hasChanged) {
|
||||
return $stmtsAware;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
private function shouldSkip(Stmt $stmt) : bool
|
||||
{
|
||||
if (!$stmt instanceof Expression) {
|
||||
return \true;
|
||||
}
|
||||
if (!$stmt->expr instanceof FuncCall) {
|
||||
return \true;
|
||||
}
|
||||
if (!$this->isName($stmt->expr, 'parse_str')) {
|
||||
return \true;
|
||||
}
|
||||
return isset($stmt->expr->args[1]);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,12 +19,12 @@ final class VersionResolver
|
|||
* @api
|
||||
* @var string
|
||||
*/
|
||||
public const PACKAGE_VERSION = '0.15.24';
|
||||
public const PACKAGE_VERSION = 'f8e3c7b0644e4e106e18e3177bcd5eb110e9ab31';
|
||||
/**
|
||||
* @api
|
||||
* @var string
|
||||
*/
|
||||
public const RELEASE_DATE = '2023-04-05 08:38:04';
|
||||
public const RELEASE_DATE = '2023-04-06 00:33:25';
|
||||
/**
|
||||
* @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 ComposerAutoloaderInitc54d4b9c00fdd6e8e65d89d3d4469299::getLoader();
|
||||
return ComposerAutoloaderInitfac1b827138adf9bd80b0f9b96bca319::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 ComposerAutoloaderInitc54d4b9c00fdd6e8e65d89d3d4469299
|
||||
class ComposerAutoloaderInitfac1b827138adf9bd80b0f9b96bca319
|
||||
{
|
||||
private static $loader;
|
||||
|
||||
|
@ -22,17 +22,17 @@ class ComposerAutoloaderInitc54d4b9c00fdd6e8e65d89d3d4469299
|
|||
return self::$loader;
|
||||
}
|
||||
|
||||
spl_autoload_register(array('ComposerAutoloaderInitc54d4b9c00fdd6e8e65d89d3d4469299', 'loadClassLoader'), true, true);
|
||||
spl_autoload_register(array('ComposerAutoloaderInitfac1b827138adf9bd80b0f9b96bca319', 'loadClassLoader'), true, true);
|
||||
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__));
|
||||
spl_autoload_unregister(array('ComposerAutoloaderInitc54d4b9c00fdd6e8e65d89d3d4469299', 'loadClassLoader'));
|
||||
spl_autoload_unregister(array('ComposerAutoloaderInitfac1b827138adf9bd80b0f9b96bca319', 'loadClassLoader'));
|
||||
|
||||
require __DIR__ . '/autoload_static.php';
|
||||
call_user_func(\Composer\Autoload\ComposerStaticInitc54d4b9c00fdd6e8e65d89d3d4469299::getInitializer($loader));
|
||||
call_user_func(\Composer\Autoload\ComposerStaticInitfac1b827138adf9bd80b0f9b96bca319::getInitializer($loader));
|
||||
|
||||
$loader->setClassMapAuthoritative(true);
|
||||
$loader->register(true);
|
||||
|
||||
$filesToLoad = \Composer\Autoload\ComposerStaticInitc54d4b9c00fdd6e8e65d89d3d4469299::$files;
|
||||
$filesToLoad = \Composer\Autoload\ComposerStaticInitfac1b827138adf9bd80b0f9b96bca319::$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 ComposerStaticInitc54d4b9c00fdd6e8e65d89d3d4469299
|
||||
class ComposerStaticInitfac1b827138adf9bd80b0f9b96bca319
|
||||
{
|
||||
public static $files = array (
|
||||
'ad155f8f1cf0d418fe49e248db8c661b' => __DIR__ . '/..' . '/react/promise/src/functions_include.php',
|
||||
|
@ -3132,9 +3132,9 @@ class ComposerStaticInitc54d4b9c00fdd6e8e65d89d3d4469299
|
|||
public static function getInitializer(ClassLoader $loader)
|
||||
{
|
||||
return \Closure::bind(function () use ($loader) {
|
||||
$loader->prefixLengthsPsr4 = ComposerStaticInitc54d4b9c00fdd6e8e65d89d3d4469299::$prefixLengthsPsr4;
|
||||
$loader->prefixDirsPsr4 = ComposerStaticInitc54d4b9c00fdd6e8e65d89d3d4469299::$prefixDirsPsr4;
|
||||
$loader->classMap = ComposerStaticInitc54d4b9c00fdd6e8e65d89d3d4469299::$classMap;
|
||||
$loader->prefixLengthsPsr4 = ComposerStaticInitfac1b827138adf9bd80b0f9b96bca319::$prefixLengthsPsr4;
|
||||
$loader->prefixDirsPsr4 = ComposerStaticInitfac1b827138adf9bd80b0f9b96bca319::$prefixDirsPsr4;
|
||||
$loader->classMap = ComposerStaticInitfac1b827138adf9bd80b0f9b96bca319::$classMap;
|
||||
|
||||
}, null, ClassLoader::class);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user