mirror of
https://github.com/rectorphp/rector.git
synced 2025-01-17 21:38:22 +01:00
Updated Rector to commit 10346eea20d2222819f59b2ae994acc0948352e4
10346eea20
Apply node->isFirstCallable() check early before ->getArgs() when possible on CallLike (#3038)
This commit is contained in:
parent
bde184a1bc
commit
bba6495f7d
@ -17,6 +17,9 @@ final class ParametersAcceptorSelectorVariantsWrapper
|
||||
public static function select($reflection, CallLike $callLike, Scope $scope) : ParametersAcceptor
|
||||
{
|
||||
$variants = $reflection->getVariants();
|
||||
if ($callLike->isFirstClassCallable()) {
|
||||
return ParametersAcceptorSelector::selectSingle($variants);
|
||||
}
|
||||
return \count($variants) > 1 ? ParametersAcceptorSelector::selectFromArgs($scope, $callLike->getArgs(), $variants) : ParametersAcceptorSelector::selectSingle($variants);
|
||||
}
|
||||
}
|
||||
|
@ -42,7 +42,7 @@ final class FuncCallValueResolver implements NodeValueResolverInterface
|
||||
if ($expr->name instanceof Name && $expr->name->toString() === 'getcwd') {
|
||||
return \dirname($currentFilePath);
|
||||
}
|
||||
$args = $expr->getArgs();
|
||||
$args = $expr->isFirstClassCallable() ? [] : $expr->getArgs();
|
||||
$arguments = [];
|
||||
foreach ($args as $arg) {
|
||||
$arguments[] = $this->constExprEvaluator->evaluateDirectly($arg->value);
|
||||
|
@ -50,6 +50,9 @@ CODE_SAMPLE
|
||||
if (!$this->nodeNameResolver->isName($node, 'in_array')) {
|
||||
return null;
|
||||
}
|
||||
if ($node->isFirstClassCallable()) {
|
||||
return null;
|
||||
}
|
||||
$args = $node->getArgs();
|
||||
$secondArg = $args[1];
|
||||
$arrayVariable = $secondArg->value;
|
||||
|
@ -51,6 +51,9 @@ CODE_SAMPLE
|
||||
if (!$this->isName($funcCall, 'array_push')) {
|
||||
return null;
|
||||
}
|
||||
if ($funcCall->isFirstClassCallable()) {
|
||||
return null;
|
||||
}
|
||||
if ($this->hasArraySpread($funcCall)) {
|
||||
return null;
|
||||
}
|
||||
|
@ -79,6 +79,9 @@ CODE_SAMPLE
|
||||
if ($this->compactConverter->hasAllArgumentsNamed($node)) {
|
||||
return $this->compactConverter->convertToArray($node);
|
||||
}
|
||||
if ($node->isFirstClassCallable()) {
|
||||
return null;
|
||||
}
|
||||
$firstArg = $node->getArgs()[0];
|
||||
$firstValue = $firstArg->value;
|
||||
$firstValueStaticType = $this->getType($firstValue);
|
||||
|
@ -58,6 +58,9 @@ CODE_SAMPLE
|
||||
if (!$this->isName($node->name, 'is_a')) {
|
||||
return null;
|
||||
}
|
||||
if ($node->isFirstClassCallable()) {
|
||||
return null;
|
||||
}
|
||||
$args = $node->getArgs();
|
||||
$firstArgValue = $args[0]->value;
|
||||
if (!$this->isFirstObjectType($firstArgValue)) {
|
||||
|
@ -196,6 +196,9 @@ CODE_SAMPLE
|
||||
if (!$expr instanceof CallLike) {
|
||||
return $this->isUsedInPreviousAssign($assign, $expr);
|
||||
}
|
||||
if ($expr->isFirstClassCallable()) {
|
||||
return \false;
|
||||
}
|
||||
foreach ($expr->getArgs() as $arg) {
|
||||
$variable = $arg->value;
|
||||
if ($this->isUsedInPreviousAssign($assign, $variable)) {
|
||||
|
@ -130,6 +130,9 @@ CODE_SAMPLE
|
||||
*/
|
||||
private function cleanupArgs(MethodCall $methodCall, array $keysArg) : void
|
||||
{
|
||||
if ($methodCall->isFirstClassCallable()) {
|
||||
return;
|
||||
}
|
||||
$args = $methodCall->getArgs();
|
||||
foreach (\array_keys($args) as $key) {
|
||||
if (\in_array($key, $keysArg, \true)) {
|
||||
|
@ -53,7 +53,7 @@ final class VariableAndCallAssignMatcher
|
||||
if (!$functionLike instanceof FunctionLike) {
|
||||
return null;
|
||||
}
|
||||
$isVariableFoundInCallArgs = (bool) $this->betterNodeFinder->findFirst($call->getArgs(), function (Node $subNode) use($variableName) : bool {
|
||||
$isVariableFoundInCallArgs = (bool) $this->betterNodeFinder->findFirst($call->isFirstClassCallable() ? [] : $call->getArgs(), function (Node $subNode) use($variableName) : bool {
|
||||
return $subNode instanceof Variable && $this->nodeNameResolver->isName($subNode, $variableName);
|
||||
});
|
||||
if ($isVariableFoundInCallArgs) {
|
||||
|
@ -12,6 +12,7 @@ use PhpParser\Node\Name\FullyQualified;
|
||||
use PhpParser\Node\Stmt;
|
||||
use PhpParser\Node\Stmt\Expression;
|
||||
use PhpParser\Node\Stmt\Return_;
|
||||
use PhpParser\Node\VariadicPlaceholder;
|
||||
use Rector\Core\Contract\Rector\ConfigurableRectorInterface;
|
||||
use Rector\Core\Rector\AbstractRector;
|
||||
use Rector\Transform\ValueObject\StaticCallRecipe;
|
||||
@ -93,7 +94,7 @@ CODE_SAMPLE
|
||||
private function createStaticCall(FuncCall $fileGetContentsFuncCall) : StaticCall
|
||||
{
|
||||
$fullyQualified = new FullyQualified($this->staticCallRecipe->getClassName());
|
||||
return new StaticCall($fullyQualified, $this->staticCallRecipe->getMethodName(), $fileGetContentsFuncCall->getArgs());
|
||||
return new StaticCall($fullyQualified, $this->staticCallRecipe->getMethodName(), $fileGetContentsFuncCall->isFirstClassCallable() ? [new VariadicPlaceholder()] : $fileGetContentsFuncCall->getArgs());
|
||||
}
|
||||
private function processStmt(?Stmt $previousStmt, Stmt $currentStmt) : bool
|
||||
{
|
||||
|
@ -17,12 +17,12 @@ final class VersionResolver
|
||||
* @api
|
||||
* @var string
|
||||
*/
|
||||
public const PACKAGE_VERSION = '84361b82b630d31b49b009b46bdd3b1312ced2e8';
|
||||
public const PACKAGE_VERSION = '10346eea20d2222819f59b2ae994acc0948352e4';
|
||||
/**
|
||||
* @api
|
||||
* @var string
|
||||
*/
|
||||
public const RELEASE_DATE = '2022-11-07 10:41:16';
|
||||
public const RELEASE_DATE = '2022-11-07 18:22:38';
|
||||
/**
|
||||
* @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 ComposerAutoloaderInitb296b7154d7a74f42d1292c2511daecf::getLoader();
|
||||
return ComposerAutoloaderInite40be044087bafda59efd8531e8e88af::getLoader();
|
||||
|
14
vendor/composer/autoload_real.php
vendored
14
vendor/composer/autoload_real.php
vendored
@ -2,7 +2,7 @@
|
||||
|
||||
// autoload_real.php @generated by Composer
|
||||
|
||||
class ComposerAutoloaderInitb296b7154d7a74f42d1292c2511daecf
|
||||
class ComposerAutoloaderInite40be044087bafda59efd8531e8e88af
|
||||
{
|
||||
private static $loader;
|
||||
|
||||
@ -22,19 +22,19 @@ class ComposerAutoloaderInitb296b7154d7a74f42d1292c2511daecf
|
||||
return self::$loader;
|
||||
}
|
||||
|
||||
spl_autoload_register(array('ComposerAutoloaderInitb296b7154d7a74f42d1292c2511daecf', 'loadClassLoader'), true, true);
|
||||
spl_autoload_register(array('ComposerAutoloaderInite40be044087bafda59efd8531e8e88af', 'loadClassLoader'), true, true);
|
||||
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__));
|
||||
spl_autoload_unregister(array('ComposerAutoloaderInitb296b7154d7a74f42d1292c2511daecf', 'loadClassLoader'));
|
||||
spl_autoload_unregister(array('ComposerAutoloaderInite40be044087bafda59efd8531e8e88af', 'loadClassLoader'));
|
||||
|
||||
require __DIR__ . '/autoload_static.php';
|
||||
call_user_func(\Composer\Autoload\ComposerStaticInitb296b7154d7a74f42d1292c2511daecf::getInitializer($loader));
|
||||
call_user_func(\Composer\Autoload\ComposerStaticInite40be044087bafda59efd8531e8e88af::getInitializer($loader));
|
||||
|
||||
$loader->setClassMapAuthoritative(true);
|
||||
$loader->register(true);
|
||||
|
||||
$includeFiles = \Composer\Autoload\ComposerStaticInitb296b7154d7a74f42d1292c2511daecf::$files;
|
||||
$includeFiles = \Composer\Autoload\ComposerStaticInite40be044087bafda59efd8531e8e88af::$files;
|
||||
foreach ($includeFiles as $fileIdentifier => $file) {
|
||||
composerRequireb296b7154d7a74f42d1292c2511daecf($fileIdentifier, $file);
|
||||
composerRequiree40be044087bafda59efd8531e8e88af($fileIdentifier, $file);
|
||||
}
|
||||
|
||||
return $loader;
|
||||
@ -46,7 +46,7 @@ class ComposerAutoloaderInitb296b7154d7a74f42d1292c2511daecf
|
||||
* @param string $file
|
||||
* @return void
|
||||
*/
|
||||
function composerRequireb296b7154d7a74f42d1292c2511daecf($fileIdentifier, $file)
|
||||
function composerRequiree40be044087bafda59efd8531e8e88af($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 ComposerStaticInitb296b7154d7a74f42d1292c2511daecf
|
||||
class ComposerStaticInite40be044087bafda59efd8531e8e88af
|
||||
{
|
||||
public static $files = array (
|
||||
'ad155f8f1cf0d418fe49e248db8c661b' => __DIR__ . '/..' . '/react/promise/src/functions_include.php',
|
||||
@ -3053,9 +3053,9 @@ class ComposerStaticInitb296b7154d7a74f42d1292c2511daecf
|
||||
public static function getInitializer(ClassLoader $loader)
|
||||
{
|
||||
return \Closure::bind(function () use ($loader) {
|
||||
$loader->prefixLengthsPsr4 = ComposerStaticInitb296b7154d7a74f42d1292c2511daecf::$prefixLengthsPsr4;
|
||||
$loader->prefixDirsPsr4 = ComposerStaticInitb296b7154d7a74f42d1292c2511daecf::$prefixDirsPsr4;
|
||||
$loader->classMap = ComposerStaticInitb296b7154d7a74f42d1292c2511daecf::$classMap;
|
||||
$loader->prefixLengthsPsr4 = ComposerStaticInite40be044087bafda59efd8531e8e88af::$prefixLengthsPsr4;
|
||||
$loader->prefixDirsPsr4 = ComposerStaticInite40be044087bafda59efd8531e8e88af::$prefixDirsPsr4;
|
||||
$loader->classMap = ComposerStaticInite40be044087bafda59efd8531e8e88af::$classMap;
|
||||
|
||||
}, null, ClassLoader::class);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user