diff --git a/phpcs.xml b/phpcs.xml index e48c9dd..edd8538 100644 --- a/phpcs.xml +++ b/phpcs.xml @@ -4,7 +4,22 @@ - src/Rector tests/test_apps tests/TestCase/Rector + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + diff --git a/src/Rector/NodeAnalyzer/FluentChainMethodCallNodeAnalyzer.php b/src/Rector/NodeAnalyzer/FluentChainMethodCallNodeAnalyzer.php index 1be55e8..2a631e8 100644 --- a/src/Rector/NodeAnalyzer/FluentChainMethodCallNodeAnalyzer.php +++ b/src/Rector/NodeAnalyzer/FluentChainMethodCallNodeAnalyzer.php @@ -1,5 +1,5 @@ var; while ($callerNode instanceof MethodCall && $callerNode->var instanceof MethodCall) { @@ -29,17 +29,20 @@ public function resolveRootMethodCall(MethodCall $methodCall) : ?MethodCall if ($callerNode instanceof MethodCall) { return $callerNode; } + return null; } + /** * @return \PhpParser\Node\Expr|\PhpParser\Node\Name */ - public function resolveRootExpr(MethodCall $methodCall) + public function resolveRootExpr(MethodCall $methodCall): Expr|Name { $callerNode = $methodCall->var; while ($callerNode instanceof MethodCall || $callerNode instanceof StaticCall) { $callerNode = $callerNode instanceof StaticCall ? $callerNode->class : $callerNode->var; } + return $callerNode; } } diff --git a/src/Rector/Rector/MethodCall/AddMethodCallArgsRector.php b/src/Rector/Rector/MethodCall/AddMethodCallArgsRector.php index 3229ef6..de08d2a 100644 --- a/src/Rector/Rector/MethodCall/AddMethodCallArgsRector.php +++ b/src/Rector/Rector/MethodCall/AddMethodCallArgsRector.php @@ -25,7 +25,7 @@ final class AddMethodCallArgsRector extends AbstractRector implements Configurab public const ADD_METHOD_CALL_ARGS = 'add_method_call_args'; /** - * @var \Cake\Upgrade\Rector\ValueObject\AddMethodCallArgs[] + * @var array<\Cake\Upgrade\Rector\ValueObject\AddMethodCallArgs> */ private array $callsWithAddMethodCallArgs = []; @@ -97,7 +97,7 @@ public function refactor(Node $node): ?Node } /** - * @param mixed[] $configuration + * @param array $configuration */ public function configure(array $configuration): void { diff --git a/src/Rector/Rector/MethodCall/ArrayToFluentCallRector.php b/src/Rector/Rector/MethodCall/ArrayToFluentCallRector.php index b509375..6f69669 100644 --- a/src/Rector/Rector/MethodCall/ArrayToFluentCallRector.php +++ b/src/Rector/Rector/MethodCall/ArrayToFluentCallRector.php @@ -3,13 +3,13 @@ namespace Cake\Upgrade\Rector\Rector\MethodCall; +use Cake\Upgrade\Rector\ValueObject\ArrayItemsAndFluentClass; +use Cake\Upgrade\Rector\ValueObject\ArrayToFluentCall; +use Cake\Upgrade\Rector\ValueObject\FactoryMethod; use PhpParser\Node; use PhpParser\Node\Expr\Array_; use PhpParser\Node\Expr\MethodCall; use PhpParser\Node\Scalar\String_; -use Cake\Upgrade\Rector\ValueObject\ArrayItemsAndFluentClass; -use Cake\Upgrade\Rector\ValueObject\ArrayToFluentCall; -use Cake\Upgrade\Rector\ValueObject\FactoryMethod; use Rector\Contract\Rector\ConfigurableRectorInterface; use Rector\Rector\AbstractRector; use Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample; @@ -31,12 +31,12 @@ final class ArrayToFluentCallRector extends AbstractRector implements Configurab public const FACTORY_METHODS = 'factory_methods'; /** - * @var \Cake\Upgrade\Rector\ValueObject\ArrayToFluentCall[] + * @var array<\Cake\Upgrade\Rector\ValueObject\ArrayToFluentCall> */ private array $arraysToFluentCalls = []; /** - * @var \Cake\Upgrade\Rector\ValueObject\FactoryMethod[] + * @var array<\Cake\Upgrade\Rector\ValueObject\FactoryMethod> */ private array $factoryMethods = []; @@ -115,7 +115,7 @@ public function refactor(Node $node): ?Node } /** - * @param mixed[] $configuration + * @param array $configuration */ public function configure(array $configuration): void { diff --git a/src/Rector/Rector/MethodCall/ModalToGetSetRector.php b/src/Rector/Rector/MethodCall/ModalToGetSetRector.php index fc697aa..82b6be9 100644 --- a/src/Rector/Rector/MethodCall/ModalToGetSetRector.php +++ b/src/Rector/Rector/MethodCall/ModalToGetSetRector.php @@ -3,11 +3,11 @@ namespace Cake\Upgrade\Rector\Rector\MethodCall; +use Cake\Upgrade\Rector\ValueObject\ModalToGetSet; use PhpParser\Node; use PhpParser\Node\Expr\Array_; use PhpParser\Node\Expr\MethodCall; use PhpParser\Node\Identifier; -use Cake\Upgrade\Rector\ValueObject\ModalToGetSet; use Rector\Contract\Rector\ConfigurableRectorInterface; use Rector\Rector\AbstractRector; use Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample; @@ -27,7 +27,7 @@ final class ModalToGetSetRector extends AbstractRector implements ConfigurableRe public const UNPREFIXED_METHODS_TO_GET_SET = 'unprefixed_methods_to_get_set'; /** - * @var \Cake\Upgrade\Rector\ValueObject\ModalToGetSet[] + * @var array<\Cake\Upgrade\Rector\ValueObject\ModalToGetSet> */ private array $unprefixedMethodsToGetSet = []; @@ -92,7 +92,7 @@ public function refactor(Node $node): ?Node } /** - * @param mixed[] $configuration + * @param array $configuration */ public function configure(array $configuration): void { diff --git a/src/Rector/Rector/MethodCall/OptionsArrayToNamedParametersRector.php b/src/Rector/Rector/MethodCall/OptionsArrayToNamedParametersRector.php index 8dd9c5c..b223ce2 100644 --- a/src/Rector/Rector/MethodCall/OptionsArrayToNamedParametersRector.php +++ b/src/Rector/Rector/MethodCall/OptionsArrayToNamedParametersRector.php @@ -3,58 +3,58 @@ namespace Cake\Upgrade\Rector\Rector\MethodCall; +use Cake\Upgrade\Rector\ValueObject\OptionsArrayToNamedParameters; use PhpParser\Node; +use PhpParser\Node\Arg; use PhpParser\Node\Expr\Array_; use PhpParser\Node\Expr\MethodCall; -use PhpParser\Node\Scalar\String_; -use Cake\Upgrade\Rector\ValueObject\OptionsArrayToNamedParameters; -use PhpParser\Node\Arg; use PhpParser\Node\Identifier; use Rector\Contract\Rector\ConfigurableRectorInterface; use Rector\Rector\AbstractRector; use Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample; use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; -use function RectorPrefix202304\dump_node; - final class OptionsArrayToNamedParametersRector extends AbstractRector implements ConfigurableRectorInterface { public const OPTIONS_TO_NAMED_PARAMETERS = 'options_to_named_parameters'; /** - * @var \Cake\Upgrade\Rector\ValueObject\OptionsArrayToNamedParameters + * @var array<\Cake\Upgrade\Rector\ValueObject\OptionsArrayToNamedParameters> */ - private $optionsToNamed = []; + private array $optionsToNamed = []; public function getRuleDefinition(): RuleDefinition { - return new RuleDefinition('Converts trailing options arrays into named parameters. Will preserve all other arguments.', [ - new ConfiguredCodeSample( - <<<'CODE_SAMPLE' -use Cake\ORM\TableRegistry; - -$articles = TableRegistry::get('Articles'); - -$query = $articles->find('list', ['field' => ['title']]); -$query = $articles->find('all', ['conditions' => ['Articles.title' => $title]]); -CODE_SAMPLE - , - <<<'CODE_SAMPLE' -use Cake\ORM\TableRegistry; - -$articles = TableRegistry::get('Articles'); - -$query = $articles->find('list', field: ['title']]); -$query = $articles->find('all', conditions: ['Articles.title' => $title]); -CODE_SAMPLE - , - [ + return new RuleDefinition( + 'Converts trailing options arrays into named parameters. Will preserve all other arguments.', + [ + new ConfiguredCodeSample( + <<<'CODE_SAMPLE' + use Cake\ORM\TableRegistry; + + $articles = TableRegistry::get('Articles'); + + $query = $articles->find('list', ['field' => ['title']]); + $query = $articles->find('all', ['conditions' => ['Articles.title' => $title]]); + CODE_SAMPLE + , + <<<'CODE_SAMPLE' + use Cake\ORM\TableRegistry; + + $articles = TableRegistry::get('Articles'); + + $query = $articles->find('list', field: ['title']]); + $query = $articles->find('all', conditions: ['Articles.title' => $title]); + CODE_SAMPLE + , [ - new OptionsArrayToNamedParameters('Table', ['find']), - ], - ] - ), - ]); + [ + new OptionsArrayToNamedParameters('Table', ['find']), + ], + ] + ), + ] + ); } /** @@ -82,14 +82,17 @@ public function refactor(Node $node): ?Node if (!$this->matchTypeAndMethodName($optionsToNamed, $node)) { continue; } - return $this->replaceMethodCall($optionsToNamed, $node); + return $this->replaceMethodCall($optionsToNamed, $node); } + return null; } - private function matchtypeAndMethodName(OptionsArrayToNamedParameters $optionsToNamed, MethodCall $methodCall): bool - { + private function matchtypeAndMethodName( + OptionsArrayToNamedParameters $optionsToNamed, + MethodCall $methodCall + ): bool { if (!$this->isObjectType($methodCall->var, $optionsToNamed->getObjectType())) { return false; } @@ -97,8 +100,10 @@ private function matchtypeAndMethodName(OptionsArrayToNamedParameters $optionsTo return $methodCall->name == $optionsToNamed->getMethod(); } - private function replaceMethodCall(OptionsArrayToNamedParameters $optionsToNamed, MethodCall $methodCall): ?MethodCall - { + private function replaceMethodCall( + OptionsArrayToNamedParameters $optionsToNamed, + MethodCall $methodCall + ): ?MethodCall { $argCount = count($methodCall->args); // Only modify method calls that have exactly two arguments. // This is important for idempotency. diff --git a/src/Rector/Rector/MethodCall/RemoveIntermediaryMethodRector.php b/src/Rector/Rector/MethodCall/RemoveIntermediaryMethodRector.php index 00912d0..6264dea 100644 --- a/src/Rector/Rector/MethodCall/RemoveIntermediaryMethodRector.php +++ b/src/Rector/Rector/MethodCall/RemoveIntermediaryMethodRector.php @@ -3,12 +3,12 @@ namespace Cake\Upgrade\Rector\Rector\MethodCall; +use Cake\Upgrade\Rector\NodeAnalyzer\FluentChainMethodCallNodeAnalyzer; +use Cake\Upgrade\Rector\ValueObject\RemoveIntermediaryMethod; use PhpParser\Node; use PhpParser\Node\Expr\MethodCall; use PhpParser\Node\Expr\Variable; use PhpParser\Node\Identifier; -use Cake\Upgrade\Rector\NodeAnalyzer\FluentChainMethodCallNodeAnalyzer; -use Cake\Upgrade\Rector\ValueObject\RemoveIntermediaryMethod; use Rector\Contract\Rector\ConfigurableRectorInterface; use Rector\Rector\AbstractRector; use Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample; @@ -28,7 +28,7 @@ final class RemoveIntermediaryMethodRector extends AbstractRector implements Con public const REMOVE_INTERMEDIARY_METHOD = 'remove_intermediary_method'; /** - * @var \Cake\Upgrade\Rector\ValueObject\RemoveIntermediaryMethod[] + * @var array<\Cake\Upgrade\Rector\ValueObject\RemoveIntermediaryMethod> */ private array $removeIntermediaryMethod = []; @@ -86,7 +86,7 @@ public function refactor(Node $node): ?Node } /** - * @param mixed[] $configuration + * @param array $configuration */ public function configure(array $configuration): void { diff --git a/src/Rector/Rector/MethodCall/RemoveMethodCallRector.php b/src/Rector/Rector/MethodCall/RemoveMethodCallRector.php index 3cde361..3cf371b 100644 --- a/src/Rector/Rector/MethodCall/RemoveMethodCallRector.php +++ b/src/Rector/Rector/MethodCall/RemoveMethodCallRector.php @@ -1,6 +1,5 @@ */ - private $callsWithRemoveMethodCallArgs = []; + private array $callsWithRemoveMethodCallArgs = []; public function getRuleDefinition(): RuleDefinition { @@ -36,16 +35,18 @@ public function getRuleDefinition(): RuleDefinition $obj = new SomeClass(); $obj->methodCall1(); $obj->methodCall2(); -CODE_SAMPLE, <<<'CODE_SAMPLE' +CODE_SAMPLE, + <<<'CODE_SAMPLE' $obj = new SomeClass(); $obj->methodCall2(); -CODE_SAMPLE, ['SomeClass', 'methodCall1'] - ) +CODE_SAMPLE, + ['SomeClass', 'methodCall1'] + ), ]); } /** - * @return array> + * @return array> */ public function getNodeTypes(): array { @@ -53,7 +54,7 @@ public function getNodeTypes(): array } /** - * @param Expression $node + * @param \PhpParser\Node\Stmt\Expression $node */ public function refactor(Node $node): ?int { @@ -77,7 +78,7 @@ public function refactor(Node $node): ?int } /** - * @param mixed[] $configuration + * @param array $configuration */ public function configure(array $configuration): void { diff --git a/src/Rector/Rector/MethodCall/RenameMethodCallBasedOnParameterRector.php b/src/Rector/Rector/MethodCall/RenameMethodCallBasedOnParameterRector.php index 38b9e3b..2228c9b 100644 --- a/src/Rector/Rector/MethodCall/RenameMethodCallBasedOnParameterRector.php +++ b/src/Rector/Rector/MethodCall/RenameMethodCallBasedOnParameterRector.php @@ -3,10 +3,10 @@ namespace Cake\Upgrade\Rector\Rector\MethodCall; +use Cake\Upgrade\Rector\ValueObject\RenameMethodCallBasedOnParameter; use PhpParser\Node; use PhpParser\Node\Expr\MethodCall; use PhpParser\Node\Identifier; -use Cake\Upgrade\Rector\ValueObject\RenameMethodCallBasedOnParameter; use Rector\Contract\Rector\ConfigurableRectorInterface; use Rector\PhpParser\Node\Value\ValueResolver; use Rector\Rector\AbstractRector; @@ -27,7 +27,7 @@ final class RenameMethodCallBasedOnParameterRector extends AbstractRector implem public const CALLS_WITH_PARAM_RENAMES = 'calls_with_param_renames'; /** - * @var \Cake\Upgrade\Rector\ValueObject\RenameMethodCallBasedOnParameter[] + * @var array<\Cake\Upgrade\Rector\ValueObject\RenameMethodCallBasedOnParameter> */ private array $callsWithParamRenames = []; @@ -92,7 +92,7 @@ public function refactor(Node $node): ?Node } /** - * @param mixed[] $configuration + * @param array $configuration */ public function configure(array $configuration): void { diff --git a/src/Rector/Rector/MethodCall/SetSerializeToViewBuilderRector.php b/src/Rector/Rector/MethodCall/SetSerializeToViewBuilderRector.php index 405a1f2..32d24f8 100644 --- a/src/Rector/Rector/MethodCall/SetSerializeToViewBuilderRector.php +++ b/src/Rector/Rector/MethodCall/SetSerializeToViewBuilderRector.php @@ -1,31 +1,34 @@ set(\'_serialize\', \'result\')` to `$this->viewBuilder()->setOption(\'serialize\', \'result\')`.', [ - new ConfiguredCodeSample( - <<<'CODE_SAMPLE' -$this->set('_serialize', 'result'); -CODE_SAMPLE - , - <<<'CODE_SAMPLE' -$this->viewBuilder()->setOption('serialize', 'result'); -CODE_SAMPLE - ) - ]); + public function getRuleDefinition(): RuleDefinition + { + return new RuleDefinition( + 'Change `$this->set(\'_serialize\', \'result\')` to ' . + '`$this->viewBuilder()->setOption(\'serialize\', \'result\')`.', + [ + new ConfiguredCodeSample( + <<<'CODE_SAMPLE' + $this->set('_serialize', 'result'); + CODE_SAMPLE + , + <<<'CODE_SAMPLE' + $this->viewBuilder()->setOption('serialize', 'result'); + CODE_SAMPLE + ), + ] + ); } public function getNodeTypes(): array @@ -35,7 +38,7 @@ public function getNodeTypes(): array public function refactor(Node $node): ?Node { - if(! $node instanceof MethodCall) { + if (! $node instanceof MethodCall) { return null; } @@ -63,11 +66,8 @@ private function isMethodCallMatch(MethodCall $methodCall, string $methodName, s return isset($methodCall->args[0]) && $methodCall->args[0]->value->value === $firstArgumentValue; } - public function configure(array $configuration): void { + public function configure(array $configuration): void + { // No configuration options } } - -return static function (RectorConfig $rectorConfig): void { - $rectorConfig->rule(SetSerializeToViewBuilderRector::class); -}; diff --git a/src/Rector/Rector/MethodCall/TableRegistryLocatorRector.php b/src/Rector/Rector/MethodCall/TableRegistryLocatorRector.php index 999fd69..13ba523 100644 --- a/src/Rector/Rector/MethodCall/TableRegistryLocatorRector.php +++ b/src/Rector/Rector/MethodCall/TableRegistryLocatorRector.php @@ -1,5 +1,4 @@ get('something'); CODE_SAMPLE - ) + ), ]); } @@ -34,7 +33,7 @@ public function getNodeTypes(): array public function refactor(Node $node): ?Node { - if(! $node instanceof StaticCall) { + if (! $node instanceof StaticCall) { return null; } diff --git a/src/Rector/Rector/Namespace_/AppUsesStaticCallToUseStatementRector.php b/src/Rector/Rector/Namespace_/AppUsesStaticCallToUseStatementRector.php index b406865..14df897 100644 --- a/src/Rector/Rector/Namespace_/AppUsesStaticCallToUseStatementRector.php +++ b/src/Rector/Rector/Namespace_/AppUsesStaticCallToUseStatementRector.php @@ -3,23 +3,23 @@ namespace Cake\Upgrade\Rector\Rector\Namespace_; +use Cake\Upgrade\Rector\ShortClassNameResolver; use PhpParser\Node; use PhpParser\Node\Expr\StaticCall; use PhpParser\Node\Name; +use PhpParser\Node\Stmt; use PhpParser\Node\Stmt\Declare_; use PhpParser\Node\Stmt\Namespace_; use PhpParser\Node\Stmt\Use_; use PhpParser\Node\Stmt\UseUse; -use PHPStan\Type\ObjectType; -use Cake\Upgrade\Rector\ShortClassNameResolver; -use PhpParser\Node\Stmt; use PhpParser\NodeTraverser; +use PHPStan\Type\ObjectType; use Rector\Contract\PhpParser\Node\StmtsAwareInterface; +use Rector\NodeTypeResolver\Node\AttributeKey; use Rector\PhpParser\Node\BetterNodeFinder; use Rector\PhpParser\Node\CustomNode\FileWithoutNamespace; use Rector\PhpParser\Node\Value\ValueResolver; use Rector\Rector\AbstractRector; -use Rector\NodeTypeResolver\Node\AttributeKey; use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; @@ -66,7 +66,7 @@ public function getNodeTypes(): array } /** - * @param StmtsAwareInterface $node + * @param \Rector\Contract\PhpParser\Node\StmtsAwareInterface $node */ public function refactor(Node $node): ?Node { @@ -100,8 +100,8 @@ public function refactor(Node $node): ?Node } /** - * @param Stmt[] $stmts - * @param StaticCall[] $appUsesStaticCalls + * @param array<\PhpParser\Node\Stmt> $stmts + * @param array<\PhpParser\Node\Expr\StaticCall> $appUsesStaticCalls */ private function removeCallLikeStmts(StmtsAwareInterface $node, array $stmts, array $appUsesStaticCalls): void { @@ -116,6 +116,7 @@ function (Node $subNode) use ($node, $appUsesStaticCalls, &$currentStmt) { if ($subNode instanceof Stmt) { $currentStmt = $subNode; + return null; } @@ -127,19 +128,20 @@ function (Node $subNode) use ($node, $appUsesStaticCalls, &$currentStmt) { return null; } - /** @var Stmt $currentStmt */ + /** @var \PhpParser\Node\Stmt $currentStmt */ unset($node->stmts[$currentStmt->getAttribute(AttributeKey::STMT_KEY)]); + return null; - }); + } + ); } /** - * @return \PhpParser\Node\Expr\StaticCall[] + * @return array<\PhpParser\Node\Expr\StaticCall> */ - private function collectAppUseStaticCalls(StmtsAwareInterface $node): array { - /** @var \PhpParser\Node\Expr\StaticCall[] $appUsesStaticCalls */ + /** @var array<\PhpParser\Node\Expr\StaticCall> $appUsesStaticCalls */ $appUsesStaticCalls = $this->betterNodeFinder->find($node, function (Node $node): bool { if (! $node instanceof StaticCall) { return false; @@ -157,8 +159,8 @@ private function collectAppUseStaticCalls(StmtsAwareInterface $node): array } /** - * @param \PhpParser\Node\Expr\StaticCall[] $staticCalls - * @return string[] + * @param array<\PhpParser\Node\Expr\StaticCall> $staticCalls + * @return array */ private function resolveNamesFromStaticCalls(array $staticCalls): array { @@ -171,7 +173,7 @@ private function resolveNamesFromStaticCalls(array $staticCalls): array } /** - * @param \PhpParser\Node\Stmt\Use_[] $fileWithoutNamespace + * @param array<\PhpParser\Node\Stmt\Use_> $fileWithoutNamespace */ private function refactorFile(FileWithoutNamespace $fileWithoutNamespace, array $uses): ?FileWithoutNamespace { @@ -200,13 +202,12 @@ private function createFullyQualifiedNameFromAppUsesStaticCall(StaticCall $stati } /** - * @param \PhpParser\Node\Stmt\Use_[] $fileWithoutNamespace + * @param array<\PhpParser\Node\Stmt\Use_> $fileWithoutNamespace */ private function refactorFileWithDeclare( FileWithoutNamespace $fileWithoutNamespace, array $uses ): FileWithoutNamespace { - $newStmts = []; foreach ($fileWithoutNamespace->stmts as $key => $stmt) { if ($stmt instanceof Declare_) { foreach ($uses as $use) { diff --git a/src/Rector/ShortClassNameResolver.php b/src/Rector/ShortClassNameResolver.php index 5d71f0f..7e8fea8 100644 --- a/src/Rector/ShortClassNameResolver.php +++ b/src/Rector/ShortClassNameResolver.php @@ -6,6 +6,7 @@ use Nette\Utils\Strings; use PHPStan\Reflection\ReflectionProvider; use Rector\Util\StringUtils; +use function str_contains; /** * @inspired https://github.com/cakephp/upgrade/blob/756410c8b7d5aff9daec3fa1fe750a3858d422ac/src/Shell/Task/AppUsesTask.php @@ -33,7 +34,7 @@ final class ShortClassNameResolver /** * A map of old => new for use statements that are missing * - * @var string[] + * @var array */ private const RENAME_MAP = [ 'App' => 'Cake\Core\App', @@ -102,7 +103,7 @@ public function resolveShortClassName(string $pseudoNamespace, string $shortClas // C. is not plugin nor lib custom App class? if ( - \str_contains($pseudoNamespace, '\\') && ! StringUtils::isMatch( + str_contains($pseudoNamespace, '\\') && ! StringUtils::isMatch( $pseudoNamespace, self::PLUGIN_OR_LIB_REGEX ) diff --git a/src/Rector/ValueObject/AddMethodCallArgs.php b/src/Rector/ValueObject/AddMethodCallArgs.php index 8975054..7919498 100644 --- a/src/Rector/ValueObject/AddMethodCallArgs.php +++ b/src/Rector/ValueObject/AddMethodCallArgs.php @@ -12,7 +12,7 @@ final class AddMethodCallArgs public function __construct( private string $class, private string $methodName, - ...$values + mixed ...$values ) { $this->values = $values; } diff --git a/src/Rector/ValueObject/ArrayItemsAndFluentClass.php b/src/Rector/ValueObject/ArrayItemsAndFluentClass.php index 649a11a..73400fe 100644 --- a/src/Rector/ValueObject/ArrayItemsAndFluentClass.php +++ b/src/Rector/ValueObject/ArrayItemsAndFluentClass.php @@ -6,7 +6,7 @@ final class ArrayItemsAndFluentClass { /** - * @param \PhpParser\Node\Expr\ArrayItem[] $arrayItems + * @param array<\PhpParser\Node\Expr\ArrayItem> $arrayItems * @param array $fluentCalls */ public function __construct( @@ -16,7 +16,7 @@ public function __construct( } /** - * @return \PhpParser\Node\Expr\ArrayItem[] + * @return array<\PhpParser\Node\Expr\ArrayItem> */ public function getArrayItems(): array { diff --git a/src/Rector/ValueObject/OptionsArrayToNamedParameters.php b/src/Rector/ValueObject/OptionsArrayToNamedParameters.php index 82b120d..5f29afa 100644 --- a/src/Rector/ValueObject/OptionsArrayToNamedParameters.php +++ b/src/Rector/ValueObject/OptionsArrayToNamedParameters.php @@ -39,6 +39,7 @@ public function getRenames(): array if (isset($this->methods['rename'])) { return $this->methods['rename']; } + return []; } }