diff --git a/docs/rector_rules_overview.md b/docs/rector_rules_overview.md index 4a65ebf84cc..ed961cdba91 100644 --- a/docs/rector_rules_overview.md +++ b/docs/rector_rules_overview.md @@ -1,10 +1,10 @@ -# 356 Rules Overview +# 355 Rules Overview
## Categories -- [Arguments](#arguments) (6) +- [Arguments](#arguments) (5) - [CodeQuality](#codequality) (70) @@ -254,49 +254,6 @@ return static function (RectorConfig $rectorConfig): void {
-### SwapMethodCallArgumentsRector - -Reorder arguments in method calls - -:wrench: **configure it!** - -- class: [`Rector\Arguments\Rector\MethodCall\SwapMethodCallArgumentsRector`](../rules/Arguments/Rector/MethodCall/SwapMethodCallArgumentsRector.php) - -```php -ruleWithConfiguration(SwapMethodCallArgumentsRector::class, [ - new SwapMethodCallArguments('Caller', 'call', [ - 2, - 1, - 0, - ]), - ]); -}; -``` - -↓ - -```diff - final class SomeClass - { - public function run(Caller $caller) - { -- return $caller->call('one', 'two', 'three'); -+ return $caller->call('three', 'two', 'one'); - } - } -``` - -
- ## CodeQuality ### AbsolutizeRequireAndIncludePathRector diff --git a/rules/Arguments/Rector/MethodCall/SwapMethodCallArgumentsRector.php b/rules/Arguments/Rector/MethodCall/SwapMethodCallArgumentsRector.php deleted file mode 100644 index 062f2f6eae8..00000000000 --- a/rules/Arguments/Rector/MethodCall/SwapMethodCallArgumentsRector.php +++ /dev/null @@ -1,125 +0,0 @@ -call('one', 'two', 'three'); - } -} -CODE_SAMPLE -, <<<'CODE_SAMPLE' -final class SomeClass -{ - public function run(Caller $caller) - { - return $caller->call('three', 'two', 'one'); - } -} -CODE_SAMPLE -, [new SwapMethodCallArguments('Caller', 'call', [2, 1, 0])])]); - } - /** - * @return array> - */ - public function getNodeTypes() : array - { - return [MethodCall::class, StaticCall::class]; - } - /** - * @param MethodCall|StaticCall $node - * @return \PhpParser\Node\Expr\MethodCall|\PhpParser\Node\Expr\StaticCall|null - */ - public function refactor(Node $node) - { - $isJustSwapped = (bool) $node->getAttribute(self::JUST_SWAPPED, \false); - if ($isJustSwapped) { - return null; - } - if ($node->isFirstClassCallable()) { - return null; - } - $args = $node->getArgs(); - foreach ($this->methodArgumentSwaps as $methodArgumentSwap) { - if (!$this->isName($node->name, $methodArgumentSwap->getMethod())) { - continue; - } - if (!$this->isObjectTypeMatch($node, $methodArgumentSwap->getObjectType())) { - continue; - } - $newArguments = $this->resolveNewArguments($methodArgumentSwap, $args); - if ($newArguments === []) { - return null; - } - foreach ($newArguments as $newPosition => $argument) { - $node->args[$newPosition] = $argument; - } - $node->setAttribute(self::JUST_SWAPPED, \true); - return $node; - } - return null; - } - public function configure(array $configuration) : void - { - Assert::allIsAOf($configuration, SwapMethodCallArguments::class); - $this->methodArgumentSwaps = $configuration; - } - /** - * @param \PhpParser\Node\Expr\MethodCall|\PhpParser\Node\Expr\StaticCall $node - */ - private function isObjectTypeMatch($node, ObjectType $objectType) : bool - { - if ($node instanceof MethodCall) { - return $this->isObjectType($node->var, $objectType); - } - return $this->isObjectType($node->class, $objectType); - } - /** - * @param Arg[] $args - * @return array - */ - private function resolveNewArguments(SwapMethodCallArguments $swapMethodCallArguments, array $args) : array - { - $newArguments = []; - foreach ($swapMethodCallArguments->getOrder() as $oldPosition => $newPosition) { - if (!isset($args[$oldPosition])) { - continue; - } - if (!isset($args[$newPosition])) { - continue; - } - $newArguments[$newPosition] = $args[$oldPosition]; - } - return $newArguments; - } -} diff --git a/rules/Arguments/ValueObject/SwapMethodCallArguments.php b/rules/Arguments/ValueObject/SwapMethodCallArguments.php deleted file mode 100644 index 927efadce69..00000000000 --- a/rules/Arguments/ValueObject/SwapMethodCallArguments.php +++ /dev/null @@ -1,50 +0,0 @@ - - * @readonly - */ - private $order; - /** - * @param array $order - */ - public function __construct(string $class, string $method, array $order) - { - $this->class = $class; - $this->method = $method; - $this->order = $order; - RectorAssert::className($class); - } - public function getObjectType() : ObjectType - { - return new ObjectType($this->class); - } - public function getMethod() : string - { - return $this->method; - } - /** - * @return array - */ - public function getOrder() : array - { - return $this->order; - } -} diff --git a/src/Application/VersionResolver.php b/src/Application/VersionResolver.php index a1d31e31357..296af736085 100644 --- a/src/Application/VersionResolver.php +++ b/src/Application/VersionResolver.php @@ -19,12 +19,12 @@ final class VersionResolver * @api * @var string */ - public const PACKAGE_VERSION = '575c8d86349fae3144987da1ee705495b31335e7'; + public const PACKAGE_VERSION = 'cf1d5b0a492598b893c3fe0ac1ec1d2fcd5018c6'; /** * @api * @var string */ - public const RELEASE_DATE = '2023-08-11 09:32:07'; + public const RELEASE_DATE = '2023-08-11 11:10:32'; /** * @var int */ diff --git a/vendor/autoload.php b/vendor/autoload.php index ba34e1de328..1ea955c3860 100644 --- a/vendor/autoload.php +++ b/vendor/autoload.php @@ -22,4 +22,4 @@ if (PHP_VERSION_ID < 50600) { require_once __DIR__ . '/composer/autoload_real.php'; -return ComposerAutoloaderInit40acdc2d042f21bbee32f3edf8d89ae1::getLoader(); +return ComposerAutoloaderInit16be4751e7661197313674642b820328::getLoader(); diff --git a/vendor/composer/autoload_classmap.php b/vendor/composer/autoload_classmap.php index f350646ff5e..e3af6ef91ff 100644 --- a/vendor/composer/autoload_classmap.php +++ b/vendor/composer/autoload_classmap.php @@ -1260,13 +1260,11 @@ return array( 'Rector\\Arguments\\Rector\\FuncCall\\FunctionArgumentDefaultValueReplacerRector' => $baseDir . '/rules/Arguments/Rector/FuncCall/FunctionArgumentDefaultValueReplacerRector.php', 'Rector\\Arguments\\Rector\\FuncCall\\SwapFuncCallArgumentsRector' => $baseDir . '/rules/Arguments/Rector/FuncCall/SwapFuncCallArgumentsRector.php', 'Rector\\Arguments\\Rector\\MethodCall\\RemoveMethodCallParamRector' => $baseDir . '/rules/Arguments/Rector/MethodCall/RemoveMethodCallParamRector.php', - 'Rector\\Arguments\\Rector\\MethodCall\\SwapMethodCallArgumentsRector' => $baseDir . '/rules/Arguments/Rector/MethodCall/SwapMethodCallArgumentsRector.php', 'Rector\\Arguments\\ValueObject\\ArgumentAdder' => $baseDir . '/rules/Arguments/ValueObject/ArgumentAdder.php', 'Rector\\Arguments\\ValueObject\\RemoveMethodCallParam' => $baseDir . '/rules/Arguments/ValueObject/RemoveMethodCallParam.php', 'Rector\\Arguments\\ValueObject\\ReplaceArgumentDefaultValue' => $baseDir . '/rules/Arguments/ValueObject/ReplaceArgumentDefaultValue.php', 'Rector\\Arguments\\ValueObject\\ReplaceFuncCallArgumentDefaultValue' => $baseDir . '/rules/Arguments/ValueObject/ReplaceFuncCallArgumentDefaultValue.php', 'Rector\\Arguments\\ValueObject\\SwapFuncCallArguments' => $baseDir . '/rules/Arguments/ValueObject/SwapFuncCallArguments.php', - 'Rector\\Arguments\\ValueObject\\SwapMethodCallArguments' => $baseDir . '/rules/Arguments/ValueObject/SwapMethodCallArguments.php', 'Rector\\BetterPhpDocParser\\Annotation\\AnnotationNaming' => $baseDir . '/packages/BetterPhpDocParser/Annotation/AnnotationNaming.php', 'Rector\\BetterPhpDocParser\\Attributes\\AttributeMirrorer' => $baseDir . '/packages/BetterPhpDocParser/Attributes/AttributeMirrorer.php', 'Rector\\BetterPhpDocParser\\Comment\\CommentsMerger' => $baseDir . '/packages/BetterPhpDocParser/Comment/CommentsMerger.php', diff --git a/vendor/composer/autoload_real.php b/vendor/composer/autoload_real.php index 2c4c6f83e9d..b0416906737 100644 --- a/vendor/composer/autoload_real.php +++ b/vendor/composer/autoload_real.php @@ -2,7 +2,7 @@ // autoload_real.php @generated by Composer -class ComposerAutoloaderInit40acdc2d042f21bbee32f3edf8d89ae1 +class ComposerAutoloaderInit16be4751e7661197313674642b820328 { private static $loader; @@ -22,17 +22,17 @@ class ComposerAutoloaderInit40acdc2d042f21bbee32f3edf8d89ae1 return self::$loader; } - spl_autoload_register(array('ComposerAutoloaderInit40acdc2d042f21bbee32f3edf8d89ae1', 'loadClassLoader'), true, true); + spl_autoload_register(array('ComposerAutoloaderInit16be4751e7661197313674642b820328', 'loadClassLoader'), true, true); self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__)); - spl_autoload_unregister(array('ComposerAutoloaderInit40acdc2d042f21bbee32f3edf8d89ae1', 'loadClassLoader')); + spl_autoload_unregister(array('ComposerAutoloaderInit16be4751e7661197313674642b820328', 'loadClassLoader')); require __DIR__ . '/autoload_static.php'; - call_user_func(\Composer\Autoload\ComposerStaticInit40acdc2d042f21bbee32f3edf8d89ae1::getInitializer($loader)); + call_user_func(\Composer\Autoload\ComposerStaticInit16be4751e7661197313674642b820328::getInitializer($loader)); $loader->setClassMapAuthoritative(true); $loader->register(true); - $filesToLoad = \Composer\Autoload\ComposerStaticInit40acdc2d042f21bbee32f3edf8d89ae1::$files; + $filesToLoad = \Composer\Autoload\ComposerStaticInit16be4751e7661197313674642b820328::$files; $requireFile = \Closure::bind(static function ($fileIdentifier, $file) { if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) { $GLOBALS['__composer_autoload_files'][$fileIdentifier] = true; diff --git a/vendor/composer/autoload_static.php b/vendor/composer/autoload_static.php index ccdcc2bf0a3..ac640791581 100644 --- a/vendor/composer/autoload_static.php +++ b/vendor/composer/autoload_static.php @@ -4,7 +4,7 @@ namespace Composer\Autoload; -class ComposerStaticInit40acdc2d042f21bbee32f3edf8d89ae1 +class ComposerStaticInit16be4751e7661197313674642b820328 { public static $files = array ( 'ad155f8f1cf0d418fe49e248db8c661b' => __DIR__ . '/..' . '/react/promise/src/functions_include.php', @@ -1513,13 +1513,11 @@ class ComposerStaticInit40acdc2d042f21bbee32f3edf8d89ae1 'Rector\\Arguments\\Rector\\FuncCall\\FunctionArgumentDefaultValueReplacerRector' => __DIR__ . '/../..' . '/rules/Arguments/Rector/FuncCall/FunctionArgumentDefaultValueReplacerRector.php', 'Rector\\Arguments\\Rector\\FuncCall\\SwapFuncCallArgumentsRector' => __DIR__ . '/../..' . '/rules/Arguments/Rector/FuncCall/SwapFuncCallArgumentsRector.php', 'Rector\\Arguments\\Rector\\MethodCall\\RemoveMethodCallParamRector' => __DIR__ . '/../..' . '/rules/Arguments/Rector/MethodCall/RemoveMethodCallParamRector.php', - 'Rector\\Arguments\\Rector\\MethodCall\\SwapMethodCallArgumentsRector' => __DIR__ . '/../..' . '/rules/Arguments/Rector/MethodCall/SwapMethodCallArgumentsRector.php', 'Rector\\Arguments\\ValueObject\\ArgumentAdder' => __DIR__ . '/../..' . '/rules/Arguments/ValueObject/ArgumentAdder.php', 'Rector\\Arguments\\ValueObject\\RemoveMethodCallParam' => __DIR__ . '/../..' . '/rules/Arguments/ValueObject/RemoveMethodCallParam.php', 'Rector\\Arguments\\ValueObject\\ReplaceArgumentDefaultValue' => __DIR__ . '/../..' . '/rules/Arguments/ValueObject/ReplaceArgumentDefaultValue.php', 'Rector\\Arguments\\ValueObject\\ReplaceFuncCallArgumentDefaultValue' => __DIR__ . '/../..' . '/rules/Arguments/ValueObject/ReplaceFuncCallArgumentDefaultValue.php', 'Rector\\Arguments\\ValueObject\\SwapFuncCallArguments' => __DIR__ . '/../..' . '/rules/Arguments/ValueObject/SwapFuncCallArguments.php', - 'Rector\\Arguments\\ValueObject\\SwapMethodCallArguments' => __DIR__ . '/../..' . '/rules/Arguments/ValueObject/SwapMethodCallArguments.php', 'Rector\\BetterPhpDocParser\\Annotation\\AnnotationNaming' => __DIR__ . '/../..' . '/packages/BetterPhpDocParser/Annotation/AnnotationNaming.php', 'Rector\\BetterPhpDocParser\\Attributes\\AttributeMirrorer' => __DIR__ . '/../..' . '/packages/BetterPhpDocParser/Attributes/AttributeMirrorer.php', 'Rector\\BetterPhpDocParser\\Comment\\CommentsMerger' => __DIR__ . '/../..' . '/packages/BetterPhpDocParser/Comment/CommentsMerger.php', @@ -2982,9 +2980,9 @@ class ComposerStaticInit40acdc2d042f21bbee32f3edf8d89ae1 public static function getInitializer(ClassLoader $loader) { return \Closure::bind(function () use ($loader) { - $loader->prefixLengthsPsr4 = ComposerStaticInit40acdc2d042f21bbee32f3edf8d89ae1::$prefixLengthsPsr4; - $loader->prefixDirsPsr4 = ComposerStaticInit40acdc2d042f21bbee32f3edf8d89ae1::$prefixDirsPsr4; - $loader->classMap = ComposerStaticInit40acdc2d042f21bbee32f3edf8d89ae1::$classMap; + $loader->prefixLengthsPsr4 = ComposerStaticInit16be4751e7661197313674642b820328::$prefixLengthsPsr4; + $loader->prefixDirsPsr4 = ComposerStaticInit16be4751e7661197313674642b820328::$prefixDirsPsr4; + $loader->classMap = ComposerStaticInit16be4751e7661197313674642b820328::$classMap; }, null, ClassLoader::class); }