mirror of
https://github.com/rectorphp/rector.git
synced 2025-01-17 21:38:22 +01:00
Updated Rector to commit cb30fd90e2fafe2b0bc7f6bd3f3ec2e6c09a4b09
cb30fd90e2
[Transform] Remove MethodCallToAnotherMethodCallWithArgumentsRector as unused (#3777)
This commit is contained in:
parent
4e94212010
commit
6105d98780
@ -1,4 +1,4 @@
|
||||
# 417 Rules Overview
|
||||
# 415 Rules Overview
|
||||
|
||||
<br>
|
||||
|
||||
@ -62,7 +62,7 @@
|
||||
|
||||
- [Strict](#strict) (6)
|
||||
|
||||
- [Transform](#transform) (33)
|
||||
- [Transform](#transform) (31)
|
||||
|
||||
- [TypeDeclaration](#typedeclaration) (40)
|
||||
|
||||
@ -8175,42 +8175,6 @@ return static function (RectorConfig $rectorConfig): void {
|
||||
|
||||
<br>
|
||||
|
||||
### MethodCallToAnotherMethodCallWithArgumentsRector
|
||||
|
||||
Turns old method call with specific types to new one with arguments
|
||||
|
||||
:wrench: **configure it!**
|
||||
|
||||
- class: [`Rector\Transform\Rector\MethodCall\MethodCallToAnotherMethodCallWithArgumentsRector`](../rules/Transform/Rector/MethodCall/MethodCallToAnotherMethodCallWithArgumentsRector.php)
|
||||
|
||||
```php
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
use Rector\Config\RectorConfig;
|
||||
use Rector\Transform\Rector\MethodCall\MethodCallToAnotherMethodCallWithArgumentsRector;
|
||||
use Rector\Transform\ValueObject\MethodCallToAnotherMethodCallWithArguments;
|
||||
|
||||
return static function (RectorConfig $rectorConfig): void {
|
||||
$rectorConfig->ruleWithConfiguration(MethodCallToAnotherMethodCallWithArgumentsRector::class, [
|
||||
new MethodCallToAnotherMethodCallWithArguments('Nette\DI\ServiceDefinition', 'setInject', 'addTag', [
|
||||
'inject',
|
||||
]),
|
||||
]);
|
||||
};
|
||||
```
|
||||
|
||||
↓
|
||||
|
||||
```diff
|
||||
$serviceDefinition = new Nette\DI\ServiceDefinition;
|
||||
-$serviceDefinition->setInject();
|
||||
+$serviceDefinition->addTag('inject');
|
||||
```
|
||||
|
||||
<br>
|
||||
|
||||
### MethodCallToFuncCallRector
|
||||
|
||||
Change method call to function call
|
||||
|
@ -1,69 +0,0 @@
|
||||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace Rector\Transform\Rector\MethodCall;
|
||||
|
||||
use PhpParser\Node;
|
||||
use PhpParser\Node\Expr\MethodCall;
|
||||
use PhpParser\Node\Identifier;
|
||||
use Rector\Core\Contract\Rector\ConfigurableRectorInterface;
|
||||
use Rector\Core\Rector\AbstractRector;
|
||||
use Rector\Transform\ValueObject\MethodCallToAnotherMethodCallWithArguments;
|
||||
use Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample;
|
||||
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
|
||||
use RectorPrefix202305\Webmozart\Assert\Assert;
|
||||
/**
|
||||
* @see \Rector\Tests\Transform\Rector\MethodCall\MethodCallToAnotherMethodCallWithArgumentsRector\MethodCallToAnotherMethodCallWithArgumentsRectorTest
|
||||
*/
|
||||
final class MethodCallToAnotherMethodCallWithArgumentsRector extends AbstractRector implements ConfigurableRectorInterface
|
||||
{
|
||||
/**
|
||||
* @var MethodCallToAnotherMethodCallWithArguments[]
|
||||
*/
|
||||
private $methodCallRenamesWithAddedArguments = [];
|
||||
public function getRuleDefinition() : RuleDefinition
|
||||
{
|
||||
return new RuleDefinition('Turns old method call with specific types to new one with arguments', [new ConfiguredCodeSample(<<<'CODE_SAMPLE'
|
||||
$serviceDefinition = new Nette\DI\ServiceDefinition;
|
||||
$serviceDefinition->setInject();
|
||||
CODE_SAMPLE
|
||||
, <<<'CODE_SAMPLE'
|
||||
$serviceDefinition = new Nette\DI\ServiceDefinition;
|
||||
$serviceDefinition->addTag('inject');
|
||||
CODE_SAMPLE
|
||||
, [new MethodCallToAnotherMethodCallWithArguments('Nette\\DI\\ServiceDefinition', 'setInject', 'addTag', ['inject'])])]);
|
||||
}
|
||||
/**
|
||||
* @return array<class-string<Node>>
|
||||
*/
|
||||
public function getNodeTypes() : array
|
||||
{
|
||||
return [MethodCall::class];
|
||||
}
|
||||
/**
|
||||
* @param MethodCall $node
|
||||
*/
|
||||
public function refactor(Node $node) : ?Node
|
||||
{
|
||||
foreach ($this->methodCallRenamesWithAddedArguments as $methodCallRenameWithAddedArgument) {
|
||||
if (!$this->isName($node->name, $methodCallRenameWithAddedArgument->getOldMethod())) {
|
||||
continue;
|
||||
}
|
||||
if (!$this->isObjectType($node->var, $methodCallRenameWithAddedArgument->getObjectType())) {
|
||||
continue;
|
||||
}
|
||||
$node->name = new Identifier($methodCallRenameWithAddedArgument->getNewMethod());
|
||||
$node->args = $this->nodeFactory->createArgs($methodCallRenameWithAddedArgument->getNewArguments());
|
||||
return $node;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
/**
|
||||
* @param mixed[] $configuration
|
||||
*/
|
||||
public function configure(array $configuration) : void
|
||||
{
|
||||
Assert::allIsAOf($configuration, MethodCallToAnotherMethodCallWithArguments::class);
|
||||
$this->methodCallRenamesWithAddedArguments = $configuration;
|
||||
}
|
||||
}
|
@ -1,62 +0,0 @@
|
||||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace Rector\Transform\ValueObject;
|
||||
|
||||
use PHPStan\Type\ObjectType;
|
||||
use Rector\Core\Validation\RectorAssert;
|
||||
final class MethodCallToAnotherMethodCallWithArguments
|
||||
{
|
||||
/**
|
||||
* @readonly
|
||||
* @var string
|
||||
*/
|
||||
private $type;
|
||||
/**
|
||||
* @readonly
|
||||
* @var string
|
||||
*/
|
||||
private $oldMethod;
|
||||
/**
|
||||
* @readonly
|
||||
* @var string
|
||||
*/
|
||||
private $newMethod;
|
||||
/**
|
||||
* @var mixed[]
|
||||
* @readonly
|
||||
*/
|
||||
private $newArguments;
|
||||
/**
|
||||
* @param mixed[] $newArguments
|
||||
*/
|
||||
public function __construct(string $type, string $oldMethod, string $newMethod, array $newArguments)
|
||||
{
|
||||
$this->type = $type;
|
||||
$this->oldMethod = $oldMethod;
|
||||
$this->newMethod = $newMethod;
|
||||
$this->newArguments = $newArguments;
|
||||
RectorAssert::className($type);
|
||||
RectorAssert::methodName($oldMethod);
|
||||
RectorAssert::methodName($newMethod);
|
||||
}
|
||||
public function getObjectType() : ObjectType
|
||||
{
|
||||
return new ObjectType($this->type);
|
||||
}
|
||||
public function getOldMethod() : string
|
||||
{
|
||||
return $this->oldMethod;
|
||||
}
|
||||
public function getNewMethod() : string
|
||||
{
|
||||
return $this->newMethod;
|
||||
}
|
||||
/**
|
||||
* @return mixed[]
|
||||
*/
|
||||
public function getNewArguments() : array
|
||||
{
|
||||
return $this->newArguments;
|
||||
}
|
||||
}
|
@ -19,12 +19,12 @@ final class VersionResolver
|
||||
* @api
|
||||
* @var string
|
||||
*/
|
||||
public const PACKAGE_VERSION = 'd9e17ca2c6bfc750eade85131368c8a2c35a0ca1';
|
||||
public const PACKAGE_VERSION = 'cb30fd90e2fafe2b0bc7f6bd3f3ec2e6c09a4b09';
|
||||
/**
|
||||
* @api
|
||||
* @var string
|
||||
*/
|
||||
public const RELEASE_DATE = '2023-05-08 21:06:06';
|
||||
public const RELEASE_DATE = '2023-05-08 21:14:10';
|
||||
/**
|
||||
* @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 ComposerAutoloaderInitd5b423b8c5068bd673f374fa308743a1::getLoader();
|
||||
return ComposerAutoloaderInit4b7ef3b28e4f79e09b1d95321673e9a9::getLoader();
|
||||
|
2
vendor/composer/autoload_classmap.php
vendored
2
vendor/composer/autoload_classmap.php
vendored
@ -2710,7 +2710,6 @@ return array(
|
||||
'Rector\\Transform\\Rector\\FuncCall\\FuncCallToNewRector' => $baseDir . '/rules/Transform/Rector/FuncCall/FuncCallToNewRector.php',
|
||||
'Rector\\Transform\\Rector\\FuncCall\\FuncCallToStaticCallRector' => $baseDir . '/rules/Transform/Rector/FuncCall/FuncCallToStaticCallRector.php',
|
||||
'Rector\\Transform\\Rector\\Isset_\\UnsetAndIssetToMethodCallRector' => $baseDir . '/rules/Transform/Rector/Isset_/UnsetAndIssetToMethodCallRector.php',
|
||||
'Rector\\Transform\\Rector\\MethodCall\\MethodCallToAnotherMethodCallWithArgumentsRector' => $baseDir . '/rules/Transform/Rector/MethodCall/MethodCallToAnotherMethodCallWithArgumentsRector.php',
|
||||
'Rector\\Transform\\Rector\\MethodCall\\MethodCallToFuncCallRector' => $baseDir . '/rules/Transform/Rector/MethodCall/MethodCallToFuncCallRector.php',
|
||||
'Rector\\Transform\\Rector\\MethodCall\\MethodCallToMethodCallRector' => $baseDir . '/rules/Transform/Rector/MethodCall/MethodCallToMethodCallRector.php',
|
||||
'Rector\\Transform\\Rector\\MethodCall\\MethodCallToPropertyFetchRector' => $baseDir . '/rules/Transform/Rector/MethodCall/MethodCallToPropertyFetchRector.php',
|
||||
@ -2730,7 +2729,6 @@ return array(
|
||||
'Rector\\Transform\\ValueObject\\FuncCallToMethodCall' => $baseDir . '/rules/Transform/ValueObject/FuncCallToMethodCall.php',
|
||||
'Rector\\Transform\\ValueObject\\FuncCallToStaticCall' => $baseDir . '/rules/Transform/ValueObject/FuncCallToStaticCall.php',
|
||||
'Rector\\Transform\\ValueObject\\GetAndSetToMethodCall' => $baseDir . '/rules/Transform/ValueObject/GetAndSetToMethodCall.php',
|
||||
'Rector\\Transform\\ValueObject\\MethodCallToAnotherMethodCallWithArguments' => $baseDir . '/rules/Transform/ValueObject/MethodCallToAnotherMethodCallWithArguments.php',
|
||||
'Rector\\Transform\\ValueObject\\MethodCallToFuncCall' => $baseDir . '/rules/Transform/ValueObject/MethodCallToFuncCall.php',
|
||||
'Rector\\Transform\\ValueObject\\MethodCallToMethodCall' => $baseDir . '/rules/Transform/ValueObject/MethodCallToMethodCall.php',
|
||||
'Rector\\Transform\\ValueObject\\MethodCallToPropertyFetch' => $baseDir . '/rules/Transform/ValueObject/MethodCallToPropertyFetch.php',
|
||||
|
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 ComposerAutoloaderInitd5b423b8c5068bd673f374fa308743a1
|
||||
class ComposerAutoloaderInit4b7ef3b28e4f79e09b1d95321673e9a9
|
||||
{
|
||||
private static $loader;
|
||||
|
||||
@ -22,17 +22,17 @@ class ComposerAutoloaderInitd5b423b8c5068bd673f374fa308743a1
|
||||
return self::$loader;
|
||||
}
|
||||
|
||||
spl_autoload_register(array('ComposerAutoloaderInitd5b423b8c5068bd673f374fa308743a1', 'loadClassLoader'), true, true);
|
||||
spl_autoload_register(array('ComposerAutoloaderInit4b7ef3b28e4f79e09b1d95321673e9a9', 'loadClassLoader'), true, true);
|
||||
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__));
|
||||
spl_autoload_unregister(array('ComposerAutoloaderInitd5b423b8c5068bd673f374fa308743a1', 'loadClassLoader'));
|
||||
spl_autoload_unregister(array('ComposerAutoloaderInit4b7ef3b28e4f79e09b1d95321673e9a9', 'loadClassLoader'));
|
||||
|
||||
require __DIR__ . '/autoload_static.php';
|
||||
call_user_func(\Composer\Autoload\ComposerStaticInitd5b423b8c5068bd673f374fa308743a1::getInitializer($loader));
|
||||
call_user_func(\Composer\Autoload\ComposerStaticInit4b7ef3b28e4f79e09b1d95321673e9a9::getInitializer($loader));
|
||||
|
||||
$loader->setClassMapAuthoritative(true);
|
||||
$loader->register(true);
|
||||
|
||||
$filesToLoad = \Composer\Autoload\ComposerStaticInitd5b423b8c5068bd673f374fa308743a1::$files;
|
||||
$filesToLoad = \Composer\Autoload\ComposerStaticInit4b7ef3b28e4f79e09b1d95321673e9a9::$files;
|
||||
$requireFile = \Closure::bind(static function ($fileIdentifier, $file) {
|
||||
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
|
||||
$GLOBALS['__composer_autoload_files'][$fileIdentifier] = true;
|
||||
|
10
vendor/composer/autoload_static.php
vendored
10
vendor/composer/autoload_static.php
vendored
@ -4,7 +4,7 @@
|
||||
|
||||
namespace Composer\Autoload;
|
||||
|
||||
class ComposerStaticInitd5b423b8c5068bd673f374fa308743a1
|
||||
class ComposerStaticInit4b7ef3b28e4f79e09b1d95321673e9a9
|
||||
{
|
||||
public static $files = array (
|
||||
'ad155f8f1cf0d418fe49e248db8c661b' => __DIR__ . '/..' . '/react/promise/src/functions_include.php',
|
||||
@ -2952,7 +2952,6 @@ class ComposerStaticInitd5b423b8c5068bd673f374fa308743a1
|
||||
'Rector\\Transform\\Rector\\FuncCall\\FuncCallToNewRector' => __DIR__ . '/../..' . '/rules/Transform/Rector/FuncCall/FuncCallToNewRector.php',
|
||||
'Rector\\Transform\\Rector\\FuncCall\\FuncCallToStaticCallRector' => __DIR__ . '/../..' . '/rules/Transform/Rector/FuncCall/FuncCallToStaticCallRector.php',
|
||||
'Rector\\Transform\\Rector\\Isset_\\UnsetAndIssetToMethodCallRector' => __DIR__ . '/../..' . '/rules/Transform/Rector/Isset_/UnsetAndIssetToMethodCallRector.php',
|
||||
'Rector\\Transform\\Rector\\MethodCall\\MethodCallToAnotherMethodCallWithArgumentsRector' => __DIR__ . '/../..' . '/rules/Transform/Rector/MethodCall/MethodCallToAnotherMethodCallWithArgumentsRector.php',
|
||||
'Rector\\Transform\\Rector\\MethodCall\\MethodCallToFuncCallRector' => __DIR__ . '/../..' . '/rules/Transform/Rector/MethodCall/MethodCallToFuncCallRector.php',
|
||||
'Rector\\Transform\\Rector\\MethodCall\\MethodCallToMethodCallRector' => __DIR__ . '/../..' . '/rules/Transform/Rector/MethodCall/MethodCallToMethodCallRector.php',
|
||||
'Rector\\Transform\\Rector\\MethodCall\\MethodCallToPropertyFetchRector' => __DIR__ . '/../..' . '/rules/Transform/Rector/MethodCall/MethodCallToPropertyFetchRector.php',
|
||||
@ -2972,7 +2971,6 @@ class ComposerStaticInitd5b423b8c5068bd673f374fa308743a1
|
||||
'Rector\\Transform\\ValueObject\\FuncCallToMethodCall' => __DIR__ . '/../..' . '/rules/Transform/ValueObject/FuncCallToMethodCall.php',
|
||||
'Rector\\Transform\\ValueObject\\FuncCallToStaticCall' => __DIR__ . '/../..' . '/rules/Transform/ValueObject/FuncCallToStaticCall.php',
|
||||
'Rector\\Transform\\ValueObject\\GetAndSetToMethodCall' => __DIR__ . '/../..' . '/rules/Transform/ValueObject/GetAndSetToMethodCall.php',
|
||||
'Rector\\Transform\\ValueObject\\MethodCallToAnotherMethodCallWithArguments' => __DIR__ . '/../..' . '/rules/Transform/ValueObject/MethodCallToAnotherMethodCallWithArguments.php',
|
||||
'Rector\\Transform\\ValueObject\\MethodCallToFuncCall' => __DIR__ . '/../..' . '/rules/Transform/ValueObject/MethodCallToFuncCall.php',
|
||||
'Rector\\Transform\\ValueObject\\MethodCallToMethodCall' => __DIR__ . '/../..' . '/rules/Transform/ValueObject/MethodCallToMethodCall.php',
|
||||
'Rector\\Transform\\ValueObject\\MethodCallToPropertyFetch' => __DIR__ . '/../..' . '/rules/Transform/ValueObject/MethodCallToPropertyFetch.php',
|
||||
@ -3115,9 +3113,9 @@ class ComposerStaticInitd5b423b8c5068bd673f374fa308743a1
|
||||
public static function getInitializer(ClassLoader $loader)
|
||||
{
|
||||
return \Closure::bind(function () use ($loader) {
|
||||
$loader->prefixLengthsPsr4 = ComposerStaticInitd5b423b8c5068bd673f374fa308743a1::$prefixLengthsPsr4;
|
||||
$loader->prefixDirsPsr4 = ComposerStaticInitd5b423b8c5068bd673f374fa308743a1::$prefixDirsPsr4;
|
||||
$loader->classMap = ComposerStaticInitd5b423b8c5068bd673f374fa308743a1::$classMap;
|
||||
$loader->prefixLengthsPsr4 = ComposerStaticInit4b7ef3b28e4f79e09b1d95321673e9a9::$prefixLengthsPsr4;
|
||||
$loader->prefixDirsPsr4 = ComposerStaticInit4b7ef3b28e4f79e09b1d95321673e9a9::$prefixDirsPsr4;
|
||||
$loader->classMap = ComposerStaticInit4b7ef3b28e4f79e09b1d95321673e9a9::$classMap;
|
||||
|
||||
}, null, ClassLoader::class);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user