diff --git a/docs/rector_rules_overview.md b/docs/rector_rules_overview.md index 15e77d6f6346..8b95129f29ae 100644 --- a/docs/rector_rules_overview.md +++ b/docs/rector_rules_overview.md @@ -1,10 +1,10 @@ -# 354 Rules Overview +# 353 Rules Overview
## Categories -- [Arguments](#arguments) (5) +- [Arguments](#arguments) (4) - [CodeQuality](#codequality) (70) @@ -138,27 +138,6 @@ Replaces defined map of arguments in defined methods and their calls.
-### SwapFuncCallArgumentsRector - -Reorder arguments in function calls - -:wrench: **configure it!** - -- class: [`Rector\Arguments\Rector\FuncCall\SwapFuncCallArgumentsRector`](../rules/Arguments/Rector/FuncCall/SwapFuncCallArgumentsRector.php) - -```diff - final class SomeClass - { - public function run() - { -- return some_function('one', 'two', 'three'); -+ return some_function('three', 'two', 'one'); - } - } -``` - -
- ## CodeQuality ### AbsolutizeRequireAndIncludePathRector diff --git a/rules/Arguments/Rector/FuncCall/SwapFuncCallArgumentsRector.php b/rules/Arguments/Rector/FuncCall/SwapFuncCallArgumentsRector.php deleted file mode 100644 index e24333e9a652..000000000000 --- a/rules/Arguments/Rector/FuncCall/SwapFuncCallArgumentsRector.php +++ /dev/null @@ -1,110 +0,0 @@ -> - */ - public function getNodeTypes() : array - { - return [FuncCall::class]; - } - /** - * @param FuncCall $node - */ - public function refactor(Node $node) : ?FuncCall - { - $isJustSwapped = (bool) $node->getAttribute(self::JUST_SWAPPED, \false); - if ($isJustSwapped) { - return null; - } - foreach ($this->functionArgumentSwaps as $functionArgumentSwap) { - if (!$this->isName($node, $functionArgumentSwap->getFunction())) { - continue; - } - $newArguments = $this->resolveNewArguments($functionArgumentSwap, $node); - if ($newArguments === []) { - return null; - } - foreach ($newArguments as $newPosition => $argument) { - $node->args[$newPosition] = $argument; - } - $node->setAttribute(self::JUST_SWAPPED, \true); - return $node; - } - return null; - } - /** - * @param mixed[] $configuration - */ - public function configure(array $configuration) : void - { - Assert::allIsAOf($configuration, SwapFuncCallArguments::class); - $this->functionArgumentSwaps = $configuration; - } - /** - * @return array - */ - private function resolveNewArguments(SwapFuncCallArguments $swapFuncCallArguments, FuncCall $funcCall) : array - { - $newArguments = []; - foreach ($swapFuncCallArguments->getOrder() as $oldPosition => $newPosition) { - if (!isset($funcCall->args[$oldPosition])) { - continue; - } - if (!isset($funcCall->args[$newPosition])) { - continue; - } - if (!$funcCall->args[$oldPosition] instanceof Arg) { - continue; - } - $newArguments[$newPosition] = $funcCall->args[$oldPosition]; - } - return $newArguments; - } -} diff --git a/rules/Arguments/ValueObject/SwapFuncCallArguments.php b/rules/Arguments/ValueObject/SwapFuncCallArguments.php deleted file mode 100644 index 2a1da02e73cc..000000000000 --- a/rules/Arguments/ValueObject/SwapFuncCallArguments.php +++ /dev/null @@ -1,37 +0,0 @@ - - * @readonly - */ - private $order; - /** - * @param array $order - */ - public function __construct(string $function, array $order) - { - $this->function = $function; - $this->order = $order; - } - public function getFunction() : string - { - return $this->function; - } - /** - * @return array - */ - public function getOrder() : array - { - return $this->order; - } -} diff --git a/rules/Php80/Rector/Class_/AnnotationToAttributeRector.php b/rules/Php80/Rector/Class_/AnnotationToAttributeRector.php index 1587a7d0b8ad..2ad04b04e1c9 100644 --- a/rules/Php80/Rector/Class_/AnnotationToAttributeRector.php +++ b/rules/Php80/Rector/Class_/AnnotationToAttributeRector.php @@ -31,6 +31,7 @@ use Rector\Php80\ValueObject\DoctrineTagAndAnnotationToAttribute; use Rector\PhpAttribute\NodeFactory\PhpAttributeGroupFactory; use Rector\PhpDocParser\PhpDocParser\PhpDocNodeTraverser; +use Rector\RectorGenerator\Exception\ConfigurationException; use Rector\VersionBonding\Contract\MinPhpVersionInterface; use Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample; use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; @@ -127,6 +128,9 @@ public function getNodeTypes() : array */ public function refactor(Node $node) : ?Node { + if ($this->annotationsToAttributes === []) { + throw new ConfigurationException(\sprintf('The "%s" rule requires configuration.', self::class)); + } $phpDocInfo = $this->phpDocInfoFactory->createFromNode($node); if (!$phpDocInfo instanceof PhpDocInfo) { return null; diff --git a/src/Application/VersionResolver.php b/src/Application/VersionResolver.php index defe4c751600..164a27c748e0 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 = '2f38105001867c15fb1b2001767b37566428719f'; + public const PACKAGE_VERSION = '9e8ed6c33f39aa9d7d859fb39b6f2d0344cdea0d'; /** * @api * @var string */ - public const RELEASE_DATE = '2023-08-28 13:59:30'; + public const RELEASE_DATE = '2023-08-28 14:43:08'; /** * @var int */ diff --git a/vendor/autoload.php b/vendor/autoload.php index 846bd4dc9d86..b67d8c0d6851 100644 --- a/vendor/autoload.php +++ b/vendor/autoload.php @@ -22,4 +22,4 @@ require_once __DIR__ . '/composer/autoload_real.php'; -return ComposerAutoloaderInitb1385f3edb8c9f0571c633e843dbc286::getLoader(); +return ComposerAutoloaderInit3242d5514b8f61810061aee8e5f52c95::getLoader(); diff --git a/vendor/composer/autoload_classmap.php b/vendor/composer/autoload_classmap.php index a2eb033f2fb3..2015d13060d2 100644 --- a/vendor/composer/autoload_classmap.php +++ b/vendor/composer/autoload_classmap.php @@ -933,13 +933,11 @@ 'Rector\\Arguments\\Rector\\ClassMethod\\ArgumentAdderRector' => $baseDir . '/rules/Arguments/Rector/ClassMethod/ArgumentAdderRector.php', 'Rector\\Arguments\\Rector\\ClassMethod\\ReplaceArgumentDefaultValueRector' => $baseDir . '/rules/Arguments/Rector/ClassMethod/ReplaceArgumentDefaultValueRector.php', '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\\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\\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 d1f37bf2fd20..3166e0ebd14d 100644 --- a/vendor/composer/autoload_real.php +++ b/vendor/composer/autoload_real.php @@ -2,7 +2,7 @@ // autoload_real.php @generated by Composer -class ComposerAutoloaderInitb1385f3edb8c9f0571c633e843dbc286 +class ComposerAutoloaderInit3242d5514b8f61810061aee8e5f52c95 { private static $loader; @@ -22,17 +22,17 @@ public static function getLoader() return self::$loader; } - spl_autoload_register(array('ComposerAutoloaderInitb1385f3edb8c9f0571c633e843dbc286', 'loadClassLoader'), true, true); + spl_autoload_register(array('ComposerAutoloaderInit3242d5514b8f61810061aee8e5f52c95', 'loadClassLoader'), true, true); self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__)); - spl_autoload_unregister(array('ComposerAutoloaderInitb1385f3edb8c9f0571c633e843dbc286', 'loadClassLoader')); + spl_autoload_unregister(array('ComposerAutoloaderInit3242d5514b8f61810061aee8e5f52c95', 'loadClassLoader')); require __DIR__ . '/autoload_static.php'; - call_user_func(\Composer\Autoload\ComposerStaticInitb1385f3edb8c9f0571c633e843dbc286::getInitializer($loader)); + call_user_func(\Composer\Autoload\ComposerStaticInit3242d5514b8f61810061aee8e5f52c95::getInitializer($loader)); $loader->setClassMapAuthoritative(true); $loader->register(true); - $filesToLoad = \Composer\Autoload\ComposerStaticInitb1385f3edb8c9f0571c633e843dbc286::$files; + $filesToLoad = \Composer\Autoload\ComposerStaticInit3242d5514b8f61810061aee8e5f52c95::$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 44140734d68c..6b4f27a9be47 100644 --- a/vendor/composer/autoload_static.php +++ b/vendor/composer/autoload_static.php @@ -4,7 +4,7 @@ namespace Composer\Autoload; -class ComposerStaticInitb1385f3edb8c9f0571c633e843dbc286 +class ComposerStaticInit3242d5514b8f61810061aee8e5f52c95 { public static $files = array ( 'ad155f8f1cf0d418fe49e248db8c661b' => __DIR__ . '/..' . '/react/promise/src/functions_include.php', @@ -1153,13 +1153,11 @@ class ComposerStaticInitb1385f3edb8c9f0571c633e843dbc286 'Rector\\Arguments\\Rector\\ClassMethod\\ArgumentAdderRector' => __DIR__ . '/../..' . '/rules/Arguments/Rector/ClassMethod/ArgumentAdderRector.php', 'Rector\\Arguments\\Rector\\ClassMethod\\ReplaceArgumentDefaultValueRector' => __DIR__ . '/../..' . '/rules/Arguments/Rector/ClassMethod/ReplaceArgumentDefaultValueRector.php', '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\\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\\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', @@ -2608,9 +2606,9 @@ class ComposerStaticInitb1385f3edb8c9f0571c633e843dbc286 public static function getInitializer(ClassLoader $loader) { return \Closure::bind(function () use ($loader) { - $loader->prefixLengthsPsr4 = ComposerStaticInitb1385f3edb8c9f0571c633e843dbc286::$prefixLengthsPsr4; - $loader->prefixDirsPsr4 = ComposerStaticInitb1385f3edb8c9f0571c633e843dbc286::$prefixDirsPsr4; - $loader->classMap = ComposerStaticInitb1385f3edb8c9f0571c633e843dbc286::$classMap; + $loader->prefixLengthsPsr4 = ComposerStaticInit3242d5514b8f61810061aee8e5f52c95::$prefixLengthsPsr4; + $loader->prefixDirsPsr4 = ComposerStaticInit3242d5514b8f61810061aee8e5f52c95::$prefixDirsPsr4; + $loader->classMap = ComposerStaticInit3242d5514b8f61810061aee8e5f52c95::$classMap; }, null, ClassLoader::class); }