diff --git a/rector.php b/rector.php index 794090b4f..dcb5690da 100644 --- a/rector.php +++ b/rector.php @@ -23,6 +23,7 @@ '*/Source*/*', '*/tests/*/Fixture*/Expected/*', StringClassNameToClassConstantRector::class => [__DIR__ . '/config'], + \Rector\CodingStyle\Rector\String_\UseClassKeywordForClassNameResolutionRector::class => [__DIR__ . '/config'], RenameForeachValueVariableToMatchMethodCallReturnTypeRector::class => [ // "data" => "datum" false positive @@ -49,6 +50,7 @@ ->withPreparedSets( deadCode: true, codeQuality: true, + codingStyle: true, typeDeclarations: true, privatization: true, naming: true, diff --git a/rules-tests/CodeQuality/Rector/Class_/ControllerMethodInjectionToConstructorRector/Fixture/allow_use.php.inc b/rules-tests/CodeQuality/Rector/Class_/ControllerMethodInjectionToConstructorRector/Fixture/allow_use.php.inc new file mode 100644 index 000000000..e37a7536a --- /dev/null +++ b/rules-tests/CodeQuality/Rector/Class_/ControllerMethodInjectionToConstructorRector/Fixture/allow_use.php.inc @@ -0,0 +1,53 @@ +log('level', 'value'); + }; + } +} + +?> +----- +logger->log('level', 'value'); + }; + } +} + +?> diff --git a/rules/CodeQuality/Rector/ClassMethod/ActionSuffixRemoverRector.php b/rules/CodeQuality/Rector/ClassMethod/ActionSuffixRemoverRector.php index 203075325..1d90dcaa9 100644 --- a/rules/CodeQuality/Rector/ClassMethod/ActionSuffixRemoverRector.php +++ b/rules/CodeQuality/Rector/ClassMethod/ActionSuffixRemoverRector.php @@ -93,6 +93,7 @@ private function removeSuffix(ClassMethod $classMethod, string $suffixToRemove): if ($newName === $name) { return null; } + $classMethod->name = new Identifier($newName); return $classMethod; } diff --git a/rules/CodeQuality/Rector/ClassMethod/ResponseReturnTypeControllerActionRector.php b/rules/CodeQuality/Rector/ClassMethod/ResponseReturnTypeControllerActionRector.php index 160d191d5..1a056a9ea 100644 --- a/rules/CodeQuality/Rector/ClassMethod/ResponseReturnTypeControllerActionRector.php +++ b/rules/CodeQuality/Rector/ClassMethod/ResponseReturnTypeControllerActionRector.php @@ -165,6 +165,7 @@ private function isResponseReturnMethod(ClassMethod $classMethod, array $methods if (! $methodCall->var instanceof Variable || $methodCall->var->name !== 'this') { return false; } + $functionName = $this->getName($methodCall->name); if (! in_array($functionName, $methods, true)) { return false; @@ -186,21 +187,25 @@ private function refactorResponse(ClassMethod $classMethod): ?ClassMethod return $classMethod; } + if ($this->isResponseReturnMethod($classMethod, ['file'])) { $classMethod->returnType = new FullyQualified(ResponseClass::BINARY_FILE); return $classMethod; } + if ($this->isResponseReturnMethod($classMethod, ['json'])) { $classMethod->returnType = new FullyQualified(ResponseClass::JSON); return $classMethod; } + if ($this->isResponseReturnMethod($classMethod, ['stream'])) { $classMethod->returnType = new FullyQualified(name: ResponseClass::STREAMED); return $classMethod; } + if ($this->isResponseReturnMethod($classMethod, ['render', 'forward', 'renderForm'])) { $classMethod->returnType = new FullyQualified(ResponseClass::BASIC); diff --git a/rules/CodeQuality/Rector/ClassMethod/TemplateAnnotationToThisRenderRector.php b/rules/CodeQuality/Rector/ClassMethod/TemplateAnnotationToThisRenderRector.php index 6d60d207c..0de660aed 100644 --- a/rules/CodeQuality/Rector/ClassMethod/TemplateAnnotationToThisRenderRector.php +++ b/rules/CodeQuality/Rector/ClassMethod/TemplateAnnotationToThisRenderRector.php @@ -394,6 +394,7 @@ private function refactorStmtsAwareNode( $hasChanged = true; } } + return $hasChanged; } diff --git a/rules/CodeQuality/Rector/Class_/ControllerMethodInjectionToConstructorRector.php b/rules/CodeQuality/Rector/Class_/ControllerMethodInjectionToConstructorRector.php index 23559b1bd..7867833d0 100644 --- a/rules/CodeQuality/Rector/Class_/ControllerMethodInjectionToConstructorRector.php +++ b/rules/CodeQuality/Rector/Class_/ControllerMethodInjectionToConstructorRector.php @@ -5,6 +5,7 @@ namespace Rector\Symfony\CodeQuality\Rector\Class_; use PhpParser\Node; +use PhpParser\Node\Expr\Closure; use PhpParser\Node\Expr\PropertyFetch; use PhpParser\Node\Expr\Variable; use PhpParser\Node\Identifier; @@ -149,7 +150,17 @@ public function refactor(Node $node): ?Node // replace param use with property fetch $this->traverseNodesWithCallable((array) $classMethod->stmts, function (Node $node) use ( $paramNamesToReplace - ): ?PropertyFetch { + ): Closure|null|PropertyFetch { + if ($node instanceof Closure) { + foreach ($node->uses as $key => $closureUse) { + if ($this->isNames($closureUse->var, $paramNamesToReplace)) { + unset($node->uses[$key]); + } + } + + return $node; + } + if (! $node instanceof Variable) { return null; } diff --git a/rules/Configs/Rector/Closure/FromServicePublicToDefaultsPublicRector.php b/rules/Configs/Rector/Closure/FromServicePublicToDefaultsPublicRector.php index f4f025092..3daed03af 100644 --- a/rules/Configs/Rector/Closure/FromServicePublicToDefaultsPublicRector.php +++ b/rules/Configs/Rector/Closure/FromServicePublicToDefaultsPublicRector.php @@ -126,6 +126,7 @@ public function isDefaultsCall(MethodCall $methodCall): bool if ($this->isName($currentMethodCall->name, 'defaults')) { return true; } + $currentMethodCall = $currentMethodCall->var; } diff --git a/rules/DependencyInjection/ThisGetTypeMatcher.php b/rules/DependencyInjection/ThisGetTypeMatcher.php index cd70bd982..68f2d50dd 100644 --- a/rules/DependencyInjection/ThisGetTypeMatcher.php +++ b/rules/DependencyInjection/ThisGetTypeMatcher.php @@ -56,6 +56,7 @@ private function isValidContainerCall(MethodCall $methodCall): bool if ($methodCall->var instanceof Variable && $this->nodeNameResolver->isName($methodCall->var, 'this')) { return true; } + return $methodCall->var instanceof PropertyFetch && $this->nodeNameResolver->isName( $methodCall->var->var, 'this' diff --git a/rules/SwiftMailer/Rector/ClassMethod/SwiftMessageToEmailRector.php b/rules/SwiftMailer/Rector/ClassMethod/SwiftMessageToEmailRector.php index 543a2e9b1..3d7d9bb3c 100644 --- a/rules/SwiftMailer/Rector/ClassMethod/SwiftMessageToEmailRector.php +++ b/rules/SwiftMailer/Rector/ClassMethod/SwiftMessageToEmailRector.php @@ -129,12 +129,14 @@ public function refactor(Node $node): ?Node if (! $this->isName($node->class, self::SWIFT_MESSAGE_FQN)) { return null; } + $args = $node->getArgs(); if ($args !== []) { $node = new MethodCall(new New_(new FullyQualified(self::EMAIL_FQN)), 'subject', [$args[0]]); } else { $node->class = new FullyQualified(self::EMAIL_FQN); } + $hasChanged = true; } @@ -161,6 +163,7 @@ public function refactor(Node $node): ?Node if ($name === 'attach') { $this->handleAttach($node); } + if ($name === 'getId') { $node = $this->handleId($node); } @@ -190,12 +193,15 @@ private function handleAddressMapping(MethodCall $methodCall, string $name): voi if ($this->addressesMapping[$name] !== null) { $methodCall->name = new Identifier($this->addressesMapping[$name]); } + if ($methodCall->getArgs() === []) { return; } + if (! ($firstArg = $methodCall->args[0]) instanceof Arg) { return; } + if ( $firstArg->value instanceof Array_ && $firstArg->value->items !== [] @@ -212,12 +218,14 @@ private function handleAddressMapping(MethodCall $methodCall, string $name): voi ); } } + $methodCall->args = $newArgs; } else { $addressArguments = [new Arg($firstArg->value)]; if (isset($methodCall->args[1]) && ($secondArg = $methodCall->args[1]) instanceof Arg) { $addressArguments[] = new Arg($secondArg->value); } + $methodCall->args = [new Arg($this->createAddress($addressArguments))]; } } @@ -238,6 +246,7 @@ private function handleBody(MethodCall $methodCall, string $name): void } else { $methodCall->name = new Identifier('text'); } + $methodCall->args = [$methodCall->args[0]]; } @@ -247,10 +256,12 @@ private function handleAttach(MethodCall $methodCall): void if ($node instanceof StaticCall && $this->isName($node->name, 'fromPath')) { $methodCall->args[0] = $node->args[0]; } + if ($node instanceof MethodCall) { if ($this->isName($node->name, 'setFilename')) { $methodCall->args[1] = $node->args[0]; } + if ($this->isName($node->name, 'setContentType')) { $methodCall->args[2] = $node->args[0]; } diff --git a/rules/Symfony27/Rector/MethodCall/ChangeCollectionTypeOptionNameFromTypeToEntryTypeRector.php b/rules/Symfony27/Rector/MethodCall/ChangeCollectionTypeOptionNameFromTypeToEntryTypeRector.php index 71db08a8c..ac0bbf11e 100644 --- a/rules/Symfony27/Rector/MethodCall/ChangeCollectionTypeOptionNameFromTypeToEntryTypeRector.php +++ b/rules/Symfony27/Rector/MethodCall/ChangeCollectionTypeOptionNameFromTypeToEntryTypeRector.php @@ -118,6 +118,7 @@ public function refactor(Node $node): ?Node if (! $hasChanged) { return null; } + return $node; } @@ -142,6 +143,7 @@ private function refactorOptionsArray(Array_ $optionsArray): bool $hasChanged = true; } } + return $hasChanged; } } diff --git a/rules/Symfony28/Rector/StaticCall/ParseFileRector.php b/rules/Symfony28/Rector/StaticCall/ParseFileRector.php index 3e8a055f6..e8f8e571c 100644 --- a/rules/Symfony28/Rector/StaticCall/ParseFileRector.php +++ b/rules/Symfony28/Rector/StaticCall/ParseFileRector.php @@ -128,6 +128,7 @@ private function isArgumentYamlFile(StaticCall $staticCall): bool if (! $nodeType instanceof ConstantStringType) { return false; } + return (bool) Strings::match($nodeType->getValue(), self::YAML_SUFFIX_REGEX); } } diff --git a/rules/Symfony30/Rector/ClassMethod/GetRequestRector.php b/rules/Symfony30/Rector/ClassMethod/GetRequestRector.php index bc7343fce..fc25471ce 100644 --- a/rules/Symfony30/Rector/ClassMethod/GetRequestRector.php +++ b/rules/Symfony30/Rector/ClassMethod/GetRequestRector.php @@ -130,6 +130,7 @@ private function isActionWithGetRequestInBody(ClassMethod $classMethod): bool if ($containsGetRequestMethod) { return true; } + /** @var MethodCall[] $getMethodCalls */ $getMethodCalls = $this->betterNodeFinder->find($classMethod, function (Node $node): bool { if (! $node instanceof MethodCall) { diff --git a/rules/Symfony30/Rector/MethodCall/ChangeStringCollectionOptionToConstantRector.php b/rules/Symfony30/Rector/MethodCall/ChangeStringCollectionOptionToConstantRector.php index 4cc329dc3..82cb77ddd 100644 --- a/rules/Symfony30/Rector/MethodCall/ChangeStringCollectionOptionToConstantRector.php +++ b/rules/Symfony30/Rector/MethodCall/ChangeStringCollectionOptionToConstantRector.php @@ -122,9 +122,11 @@ private function processChangeToConstant(Array_ $optionsArray, MethodCall $metho if (! $optionsArrayItem instanceof ArrayItem) { continue; } + if (! $optionsArrayItem->key instanceof Expr) { continue; } + if (! $this->valueResolver->isValues($optionsArrayItem->key, ['type', 'entry_type'])) { continue; } diff --git a/rules/Symfony33/Rector/ClassConstFetch/ConsoleExceptionToErrorEventConstantRector.php b/rules/Symfony33/Rector/ClassConstFetch/ConsoleExceptionToErrorEventConstantRector.php index 4596af9d5..62b597b5a 100644 --- a/rules/Symfony33/Rector/ClassConstFetch/ConsoleExceptionToErrorEventConstantRector.php +++ b/rules/Symfony33/Rector/ClassConstFetch/ConsoleExceptionToErrorEventConstantRector.php @@ -9,6 +9,7 @@ use PhpParser\Node\Scalar\String_; use PHPStan\Type\ObjectType; use Rector\Rector\AbstractRector; +use Symfony\Component\Console\ConsoleEvents; use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; @@ -33,11 +34,8 @@ public function getRuleDefinition(): RuleDefinition return new RuleDefinition( 'Turns old event name with EXCEPTION to ERROR constant in Console in Symfony', [ - new CodeSample('"console.exception"', 'Symfony\Component\Console\ConsoleEvents::ERROR'), - new CodeSample( - 'Symfony\Component\Console\ConsoleEvents::EXCEPTION', - 'Symfony\Component\Console\ConsoleEvents::ERROR' - ), + new CodeSample('"console.exception"', ConsoleEvents::class . '::ERROR'), + new CodeSample(ConsoleEvents::class . '::EXCEPTION', ConsoleEvents::class . '::ERROR'), ] ); } diff --git a/rules/Symfony42/Rector/New_/StringToArrayArgumentProcessRector.php b/rules/Symfony42/Rector/New_/StringToArrayArgumentProcessRector.php index 89a1dc3e3..cc1349c6d 100644 --- a/rules/Symfony42/Rector/New_/StringToArrayArgumentProcessRector.php +++ b/rules/Symfony42/Rector/New_/StringToArrayArgumentProcessRector.php @@ -116,6 +116,7 @@ private function processArgumentPosition(New_|MethodCall $node, int $argumentPos if (! $hasChanged) { return null; } + return $node; } @@ -147,6 +148,7 @@ private function processStringType(New_|MethodCall $expr, int $argumentPosition, $args[$argumentPosition]->value = $this->nodeFactory->createArray($parts); $hasChanged = true; } + return $hasChanged; } diff --git a/rules/Symfony44/Rector/ClassMethod/ConsoleExecuteReturnIntRector.php b/rules/Symfony44/Rector/ClassMethod/ConsoleExecuteReturnIntRector.php index 3e88640cb..7878bfa67 100644 --- a/rules/Symfony44/Rector/ClassMethod/ConsoleExecuteReturnIntRector.php +++ b/rules/Symfony44/Rector/ClassMethod/ConsoleExecuteReturnIntRector.php @@ -168,6 +168,7 @@ private function isIntegerTernaryIfElse(Ternary $ternary): bool if (! $if instanceof Expr) { $if = $ternary->cond; } + /** @var Expr $else */ $else = $ternary->else; $ifType = $this->getType($if); diff --git a/rules/Symfony51/Rector/ClassMethod/CommandConstantReturnCodeRector.php b/rules/Symfony51/Rector/ClassMethod/CommandConstantReturnCodeRector.php index a06204de1..3e25db40a 100644 --- a/rules/Symfony51/Rector/ClassMethod/CommandConstantReturnCodeRector.php +++ b/rules/Symfony51/Rector/ClassMethod/CommandConstantReturnCodeRector.php @@ -97,6 +97,7 @@ public function refactor(Node $node): ?Node if (! $return->expr instanceof Int_) { continue; } + $classConstFetch = $this->convertNumberToConstant($return->expr); if (! $classConstFetch instanceof ClassConstFetch) { continue; diff --git a/rules/Symfony62/Rector/ClassMethod/ClassMethod/ArgumentValueResolverToValueResolverRector.php b/rules/Symfony62/Rector/ClassMethod/ClassMethod/ArgumentValueResolverToValueResolverRector.php index b333a7459..28ecab1ad 100644 --- a/rules/Symfony62/Rector/ClassMethod/ClassMethod/ArgumentValueResolverToValueResolverRector.php +++ b/rules/Symfony62/Rector/ClassMethod/ClassMethod/ArgumentValueResolverToValueResolverRector.php @@ -48,6 +48,7 @@ public function refactor(Node $node): ?Node $classMethod ); } + if ($this->isName( $classMethod->name, 'resolve' @@ -115,22 +116,27 @@ private function shouldRefactorClass(Class_ $class): bool private function extractSupportsArguments(Class_ $class, int $key, ClassMethod $classMethod): array { $isIdentical = true; - $supportFirstArg = $supportSecondArg = null; + $supportFirstArg = null; + $supportSecondArg = null; if ($classMethod->getStmts() === null) { return [$isIdentical, $supportFirstArg, $supportSecondArg]; } + foreach ($classMethod->getStmts() as $stmt) { if (! $stmt instanceof Return_) { continue; } + $expression = $stmt->expr; if (! $expression instanceof BinaryOp) { continue; } + if ($expression instanceof NotIdentical) { $isIdentical = false; } + $supportFirstArg = $expression->left; $supportSecondArg = $expression->right; unset($class->stmts[$key]); diff --git a/rules/Symfony62/Rector/ClassMethod/ParamConverterAttributeToMapEntityAttributeRector.php b/rules/Symfony62/Rector/ClassMethod/ParamConverterAttributeToMapEntityAttributeRector.php index 1e1eae826..c294985fb 100644 --- a/rules/Symfony62/Rector/ClassMethod/ParamConverterAttributeToMapEntityAttributeRector.php +++ b/rules/Symfony62/Rector/ClassMethod/ParamConverterAttributeToMapEntityAttributeRector.php @@ -184,9 +184,11 @@ private function getNewArguments(?Expr $mapping, ?Expr $exprValue): array ) { continue; } + if (in_array($item->key->value, ['mapping', 'entity_manager'], true)) { $probablyEntity = true; } + $newArguments[] = new Arg($item->value, name: new Identifier($item->key->value)); } @@ -244,6 +246,7 @@ private function getIndexForExprArg(array $args): ?int return $key; } } + return null; } } diff --git a/rules/Symfony62/Rector/Class_/MessageHandlerInterfaceToAttributeRector.php b/rules/Symfony62/Rector/Class_/MessageHandlerInterfaceToAttributeRector.php index 16b0a6275..7fc46d93a 100644 --- a/rules/Symfony62/Rector/Class_/MessageHandlerInterfaceToAttributeRector.php +++ b/rules/Symfony62/Rector/Class_/MessageHandlerInterfaceToAttributeRector.php @@ -131,9 +131,11 @@ private function checkForServices(Class_ $class, array $handlers): ?Class_ } } } + if ($hasChanged) { return $class; } + return null; } } diff --git a/rules/Symfony62/Rector/Class_/MessageSubscriberInterfaceToAttributeRector.php b/rules/Symfony62/Rector/Class_/MessageSubscriberInterfaceToAttributeRector.php index 65bbef8a1..e241acd2b 100644 --- a/rules/Symfony62/Rector/Class_/MessageSubscriberInterfaceToAttributeRector.php +++ b/rules/Symfony62/Rector/Class_/MessageSubscriberInterfaceToAttributeRector.php @@ -178,6 +178,7 @@ private function handleYields(Class_ $class, ClassMethod $getHandledMessagesClas ) { continue; } + $classParts = $value->class->getParts(); $this->newInvokeMethodName = 'handle' . end($classParts); $this->addAttribute($class, $method, $arguments); @@ -193,12 +194,14 @@ private function parseArguments(Array_ $array, string &$method): array if (! $item->value instanceof Expr) { continue; } + $key = (string) $this->valueResolver->getValue($item->key); $value = $this->valueResolver->getValue($item->value); if ($key === 'method') { $method = $value; continue; } + $arguments[$key] = $value; } diff --git a/rules/Symfony62/Rector/MethodCall/SimplifyFormRenderingRector.php b/rules/Symfony62/Rector/MethodCall/SimplifyFormRenderingRector.php index a809829db..2213d0523 100644 --- a/rules/Symfony62/Rector/MethodCall/SimplifyFormRenderingRector.php +++ b/rules/Symfony62/Rector/MethodCall/SimplifyFormRenderingRector.php @@ -121,12 +121,15 @@ private function processRemoveCreateView(array $arrayItems): ?array if (! $arrayItem->value instanceof MethodCall) { continue; } + if (! $this->isName($arrayItem->value->name, 'createView')) { continue; } + if (! $this->isObjectType($arrayItem->value->var, new ObjectType('Symfony\Component\Form\FormInterface'))) { continue; } + $replaced = true; $arrayItem->value = $arrayItem->value->var; } diff --git a/rules/Symfony73/NodeRemover/ReturnEmptyArrayMethodRemover.php b/rules/Symfony73/NodeRemover/ReturnEmptyArrayMethodRemover.php index ad0ec1d0b..c6f5a9893 100644 --- a/rules/Symfony73/NodeRemover/ReturnEmptyArrayMethodRemover.php +++ b/rules/Symfony73/NodeRemover/ReturnEmptyArrayMethodRemover.php @@ -12,7 +12,7 @@ final class ReturnEmptyArrayMethodRemover { public function removeClassMethodIfArrayEmpty(Class_ $class, Array_ $returnArray, string $methodName): void { - if (count($returnArray->items) !== 0) { + if ($returnArray->items !== []) { return; } diff --git a/rules/Symfony73/Rector/Class_/CommandHelpToAttributeRector.php b/rules/Symfony73/Rector/Class_/CommandHelpToAttributeRector.php index 5f5034014..ff0be791b 100644 --- a/rules/Symfony73/Rector/Class_/CommandHelpToAttributeRector.php +++ b/rules/Symfony73/Rector/Class_/CommandHelpToAttributeRector.php @@ -161,6 +161,7 @@ function (Node $node) use (&$helpString): int|null|Expr { if ($node instanceof Class_ || $node instanceof Function_) { return NodeVisitor::DONT_TRAVERSE_CURRENT_AND_CHILDREN; } + if (! $node instanceof MethodCall) { return null; } diff --git a/rules/Symfony73/Rector/Class_/ConstraintOptionsToNamedArgumentsRector.php b/rules/Symfony73/Rector/Class_/ConstraintOptionsToNamedArgumentsRector.php index 8e3ab9e97..35a190791 100644 --- a/rules/Symfony73/Rector/Class_/ConstraintOptionsToNamedArgumentsRector.php +++ b/rules/Symfony73/Rector/Class_/ConstraintOptionsToNamedArgumentsRector.php @@ -80,7 +80,7 @@ public function refactor(Node $node): ?Node } if ( - count($node->args) === 0 || + $node->args === [] || ! $node->args[0] instanceof Arg || ! $node->args[0]->value instanceof Array_ ) { diff --git a/src/Helper/MessengerHelper.php b/src/Helper/MessengerHelper.php index 44613bba3..c54eb126b 100644 --- a/src/Helper/MessengerHelper.php +++ b/src/Helper/MessengerHelper.php @@ -52,6 +52,7 @@ public function extractOptionsFromServiceDefinition(ServiceDefinition $serviceDe $options['fromTransport'] = $options['from_transport']; unset($options['from_transport']); } + return $options; } @@ -78,6 +79,7 @@ public function addAttribute(Class_|ClassMethod $node, array $options = []): Cla { $args = $this->phpAttributeGroupFactory->createArgsFromItems($options, self::AS_MESSAGE_HANDLER_ATTRIBUTE); $args = $this->attributeArrayNameInliner->inlineArrayToArgs($args); + $node->attrGroups = array_merge($node->attrGroups, [ new AttributeGroup([new Attribute(new FullyQualified(self::AS_MESSAGE_HANDLER_ATTRIBUTE), $args)]), ]); diff --git a/src/NodeAnalyzer/RouteRequiredParamNameToTypesResolver.php b/src/NodeAnalyzer/RouteRequiredParamNameToTypesResolver.php index f7a964655..40c567018 100644 --- a/src/NodeAnalyzer/RouteRequiredParamNameToTypesResolver.php +++ b/src/NodeAnalyzer/RouteRequiredParamNameToTypesResolver.php @@ -90,6 +90,7 @@ private function resolveFromAnnotation(DoctrineAnnotationTagValueNode $doctrineA if (! $requirementsArrayItemNode instanceof ArrayItemNode) { return []; } + if (! $requirementsArrayItemNode->value instanceof CurlyListNode) { return []; } diff --git a/src/NodeFactory/GetSubscribedEventsClassMethodFactory.php b/src/NodeFactory/GetSubscribedEventsClassMethodFactory.php index cefbae171..a17cae786 100644 --- a/src/NodeFactory/GetSubscribedEventsClassMethodFactory.php +++ b/src/NodeFactory/GetSubscribedEventsClassMethodFactory.php @@ -200,9 +200,11 @@ private function resolveMethodName(ServiceDefinition $serviceDefinition, string if (! $eventTag instanceof EventListenerTag) { continue; } + if ($eventTag->getEvent() !== $eventName) { continue; } + return $eventTag->getMethod(); } @@ -217,9 +219,11 @@ private function resolvePriority(ServiceDefinition $serviceDefinition, string $e if (! $eventTag instanceof EventListenerTag) { continue; } + if ($eventTag->getEvent() !== $eventName) { continue; } + return $eventTag->getPriority(); } diff --git a/src/NodeFactory/OnLogoutClassMethodFactory.php b/src/NodeFactory/OnLogoutClassMethodFactory.php index 52d767855..ad7eaf094 100644 --- a/src/NodeFactory/OnLogoutClassMethodFactory.php +++ b/src/NodeFactory/OnLogoutClassMethodFactory.php @@ -64,6 +64,7 @@ private function resolveUsedParams(ClassMethod $logoutClassMethod): array $usedParams[] = $oldParam; } + return $usedParams; } diff --git a/src/Set/SwiftMailerSetList.php b/src/Set/SwiftMailerSetList.php index 7ce8e8058..db9f6294b 100644 --- a/src/Set/SwiftMailerSetList.php +++ b/src/Set/SwiftMailerSetList.php @@ -12,5 +12,5 @@ final class SwiftMailerSetList /** * @var string */ - final public const SWIFT_TO_SYMFONY = __DIR__ . '/../../config/sets/swiftmailer/swiftmailer-to-symfony-mailer.php'; + public const SWIFT_TO_SYMFONY = __DIR__ . '/../../config/sets/swiftmailer/swiftmailer-to-symfony-mailer.php'; } diff --git a/src/Set/SymfonyInternalSetList.php b/src/Set/SymfonyInternalSetList.php index 490d629f0..2eb9287a0 100644 --- a/src/Set/SymfonyInternalSetList.php +++ b/src/Set/SymfonyInternalSetList.php @@ -18,10 +18,10 @@ final class SymfonyInternalSetList /** * @var string */ - final public const FOS_REST_ANNOTATIONS_TO_ATTRIBUTES = __DIR__ . '/../../config/sets/fosrest/annotations-to-attributes.php'; + public const FOS_REST_ANNOTATIONS_TO_ATTRIBUTES = __DIR__ . '/../../config/sets/fosrest/annotations-to-attributes.php'; /** * @var string */ - final public const SENSIOLABS_ANNOTATIONS_TO_ATTRIBUTES = __DIR__ . '/../../config/sets/sensiolabs/annotations-to-attributes.php'; + public const SENSIOLABS_ANNOTATIONS_TO_ATTRIBUTES = __DIR__ . '/../../config/sets/sensiolabs/annotations-to-attributes.php'; } diff --git a/src/Set/SymfonySetList.php b/src/Set/SymfonySetList.php index f95a3713e..b2d097fee 100644 --- a/src/Set/SymfonySetList.php +++ b/src/Set/SymfonySetList.php @@ -14,177 +14,177 @@ final class SymfonySetList /** * @var string */ - final public const CONFIGS = __DIR__ . '/../../config/sets/symfony/configs.php'; + public const CONFIGS = __DIR__ . '/../../config/sets/symfony/configs.php'; /** * @var string */ - final public const SYMFONY_25 = __DIR__ . '/../../config/sets/symfony/symfony25.php'; + public const SYMFONY_25 = __DIR__ . '/../../config/sets/symfony/symfony25.php'; /** * @var string */ - final public const SYMFONY_26 = __DIR__ . '/../../config/sets/symfony/symfony26.php'; + public const SYMFONY_26 = __DIR__ . '/../../config/sets/symfony/symfony26.php'; /** * @var string */ - final public const SYMFONY_27 = __DIR__ . '/../../config/sets/symfony/symfony27.php'; + public const SYMFONY_27 = __DIR__ . '/../../config/sets/symfony/symfony27.php'; /** * @var string */ - final public const SYMFONY_28 = __DIR__ . '/../../config/sets/symfony/symfony28.php'; + public const SYMFONY_28 = __DIR__ . '/../../config/sets/symfony/symfony28.php'; /** * @var string */ - final public const SYMFONY_30 = __DIR__ . '/../../config/sets/symfony/symfony3/symfony30.php'; + public const SYMFONY_30 = __DIR__ . '/../../config/sets/symfony/symfony3/symfony30.php'; /** * @var string */ - final public const SYMFONY_31 = __DIR__ . '/../../config/sets/symfony/symfony3/symfony31.php'; + public const SYMFONY_31 = __DIR__ . '/../../config/sets/symfony/symfony3/symfony31.php'; /** * @var string */ - final public const SYMFONY_32 = __DIR__ . '/../../config/sets/symfony/symfony3/symfony32.php'; + public const SYMFONY_32 = __DIR__ . '/../../config/sets/symfony/symfony3/symfony32.php'; /** * @var string */ - final public const SYMFONY_33 = __DIR__ . '/../../config/sets/symfony/symfony3/symfony33.php'; + public const SYMFONY_33 = __DIR__ . '/../../config/sets/symfony/symfony3/symfony33.php'; /** * @var string */ - final public const SYMFONY_34 = __DIR__ . '/../../config/sets/symfony/symfony3/symfony34.php'; + public const SYMFONY_34 = __DIR__ . '/../../config/sets/symfony/symfony3/symfony34.php'; /** * @var string */ - final public const SYMFONY_40 = __DIR__ . '/../../config/sets/symfony/symfony4/symfony40.php'; + public const SYMFONY_40 = __DIR__ . '/../../config/sets/symfony/symfony4/symfony40.php'; /** * @var string */ - final public const SYMFONY_41 = __DIR__ . '/../../config/sets/symfony/symfony4/symfony41.php'; + public const SYMFONY_41 = __DIR__ . '/../../config/sets/symfony/symfony4/symfony41.php'; /** * @var string */ - final public const SYMFONY_42 = __DIR__ . '/../../config/sets/symfony/symfony4/symfony42.php'; + public const SYMFONY_42 = __DIR__ . '/../../config/sets/symfony/symfony4/symfony42.php'; /** * @var string */ - final public const SYMFONY_43 = __DIR__ . '/../../config/sets/symfony/symfony4/symfony43.php'; + public const SYMFONY_43 = __DIR__ . '/../../config/sets/symfony/symfony4/symfony43.php'; /** * @var string */ - final public const SYMFONY_44 = __DIR__ . '/../../config/sets/symfony/symfony4/symfony44.php'; + public const SYMFONY_44 = __DIR__ . '/../../config/sets/symfony/symfony4/symfony44.php'; /** * @var string */ - final public const SYMFONY_50 = __DIR__ . '/../../config/sets/symfony/symfony5/symfony50.php'; + public const SYMFONY_50 = __DIR__ . '/../../config/sets/symfony/symfony5/symfony50.php'; /** * @var string */ - final public const SYMFONY_50_TYPES = __DIR__ . '/../../config/sets/symfony/symfony5/symfony50/symfony50-types.php'; + public const SYMFONY_50_TYPES = __DIR__ . '/../../config/sets/symfony/symfony5/symfony50/symfony50-types.php'; /** * @var string */ - final public const SYMFONY_51 = __DIR__ . '/../../config/sets/symfony/symfony5/symfony51.php'; + public const SYMFONY_51 = __DIR__ . '/../../config/sets/symfony/symfony5/symfony51.php'; /** * @var string */ - final public const SYMFONY_52 = __DIR__ . '/../../config/sets/symfony/symfony5/symfony52.php'; + public const SYMFONY_52 = __DIR__ . '/../../config/sets/symfony/symfony5/symfony52.php'; /** * @var string */ - final public const SYMFONY_53 = __DIR__ . '/../../config/sets/symfony/symfony5/symfony53.php'; + public const SYMFONY_53 = __DIR__ . '/../../config/sets/symfony/symfony5/symfony53.php'; /** * @var string */ - final public const SYMFONY_54 = __DIR__ . '/../../config/sets/symfony/symfony5/symfony54.php'; + public const SYMFONY_54 = __DIR__ . '/../../config/sets/symfony/symfony5/symfony54.php'; /** * @deprecated Use ->withAttributesSets(symfony: true) in rector.php config instead * @var string */ - final public const SYMFONY_52_VALIDATOR_ATTRIBUTES = __DIR__ . '/../../config/sets/symfony/symfony5/symfony52-validator-attributes.php'; + public const SYMFONY_52_VALIDATOR_ATTRIBUTES = __DIR__ . '/../../config/sets/symfony/symfony5/symfony52-validator-attributes.php'; /** * @var string */ - final public const SYMFONY_60 = __DIR__ . '/../../config/sets/symfony/symfony6/symfony60.php'; + public const SYMFONY_60 = __DIR__ . '/../../config/sets/symfony/symfony6/symfony60.php'; /** * @var string */ - final public const SYMFONY_61 = __DIR__ . '/../../config/sets/symfony/symfony6/symfony61.php'; + public const SYMFONY_61 = __DIR__ . '/../../config/sets/symfony/symfony6/symfony61.php'; /** * @var string */ - final public const SYMFONY_62 = __DIR__ . '/../../config/sets/symfony/symfony6/symfony62.php'; + public const SYMFONY_62 = __DIR__ . '/../../config/sets/symfony/symfony6/symfony62.php'; /** * @var string */ - final public const SYMFONY_63 = __DIR__ . '/../../config/sets/symfony/symfony6/symfony63.php'; + public const SYMFONY_63 = __DIR__ . '/../../config/sets/symfony/symfony6/symfony63.php'; /** * @var string */ - final public const SYMFONY_64 = __DIR__ . '/../../config/sets/symfony/symfony6/symfony64.php'; + public const SYMFONY_64 = __DIR__ . '/../../config/sets/symfony/symfony6/symfony64.php'; /** * @var string */ - final public const SYMFONY_70 = __DIR__ . '/../../config/sets/symfony/symfony7/symfony70.php'; + public const SYMFONY_70 = __DIR__ . '/../../config/sets/symfony/symfony7/symfony70.php'; /** * @var string */ - final public const SYMFONY_71 = __DIR__ . '/../../config/sets/symfony/symfony7/symfony71.php'; + public const SYMFONY_71 = __DIR__ . '/../../config/sets/symfony/symfony7/symfony71.php'; /** * @var string */ - final public const SYMFONY_72 = __DIR__ . '/../../config/sets/symfony/symfony7/symfony72.php'; + public const SYMFONY_72 = __DIR__ . '/../../config/sets/symfony/symfony7/symfony72.php'; /** * @var string */ - final public const SYMFONY_73 = __DIR__ . '/../../config/sets/symfony/symfony7/symfony73.php'; + public const SYMFONY_73 = __DIR__ . '/../../config/sets/symfony/symfony7/symfony73.php'; /** * @var string */ - final public const SYMFONY_74 = __DIR__ . '/../../config/sets/symfony/symfony7/symfony74.php'; + public const SYMFONY_74 = __DIR__ . '/../../config/sets/symfony/symfony7/symfony74.php'; /** * @var string */ - final public const SYMFONY_CODE_QUALITY = __DIR__ . '/../../config/sets/symfony/symfony-code-quality.php'; + public const SYMFONY_CODE_QUALITY = __DIR__ . '/../../config/sets/symfony/symfony-code-quality.php'; /** * @var string */ - final public const SYMFONY_CONSTRUCTOR_INJECTION = __DIR__ . '/../../config/sets/symfony/symfony-constructor-injection.php'; + public const SYMFONY_CONSTRUCTOR_INJECTION = __DIR__ . '/../../config/sets/symfony/symfony-constructor-injection.php'; /** * @deprecated Use ->withAttributesSets(symfony: true) in rector.php config instead * @var string */ - final public const ANNOTATIONS_TO_ATTRIBUTES = __DIR__ . '/../../config/sets/symfony/annotations-to-attributes.php'; + public const ANNOTATIONS_TO_ATTRIBUTES = __DIR__ . '/../../config/sets/symfony/annotations-to-attributes.php'; } diff --git a/src/Set/TwigSetList.php b/src/Set/TwigSetList.php index cbbff1da9..7e646fb48 100644 --- a/src/Set/TwigSetList.php +++ b/src/Set/TwigSetList.php @@ -12,35 +12,35 @@ final class TwigSetList /** * @var string */ - final public const TWIG_112 = __DIR__ . '/../../config/sets/twig/twig112.php'; + public const TWIG_112 = __DIR__ . '/../../config/sets/twig/twig112.php'; /** * @var string */ - final public const TWIG_127 = __DIR__ . '/../../config/sets/twig/twig127.php'; + public const TWIG_127 = __DIR__ . '/../../config/sets/twig/twig127.php'; /** * @var string */ - final public const TWIG_134 = __DIR__ . '/../../config/sets/twig/twig134.php'; + public const TWIG_134 = __DIR__ . '/../../config/sets/twig/twig134.php'; /** * @var string */ - final public const TWIG_140 = __DIR__ . '/../../config/sets/twig/twig140.php'; + public const TWIG_140 = __DIR__ . '/../../config/sets/twig/twig140.php'; /** * @var string */ - final public const TWIG_20 = __DIR__ . '/../../config/sets/twig/twig20.php'; + public const TWIG_20 = __DIR__ . '/../../config/sets/twig/twig20.php'; /** * @var string */ - final public const TWIG_24 = __DIR__ . '/../../config/sets/twig/twig24.php'; + public const TWIG_24 = __DIR__ . '/../../config/sets/twig/twig24.php'; /** * @var string */ - final public const TWIG_UNDERSCORE_TO_NAMESPACE = __DIR__ . '/../../config/sets/twig/twig-underscore-to-namespace.php'; + public const TWIG_UNDERSCORE_TO_NAMESPACE = __DIR__ . '/../../config/sets/twig/twig-underscore-to-namespace.php'; } diff --git a/src/TypeAnalyzer/ArrayUnionResponseTypeAnalyzer.php b/src/TypeAnalyzer/ArrayUnionResponseTypeAnalyzer.php index 767545415..cc968128f 100644 --- a/src/TypeAnalyzer/ArrayUnionResponseTypeAnalyzer.php +++ b/src/TypeAnalyzer/ArrayUnionResponseTypeAnalyzer.php @@ -36,9 +36,11 @@ public function isArrayUnionResponseType(Type $type, string $className): bool return false; } + if (! $hasArrayType) { return false; } + return $hasResponseType; } diff --git a/src/ValueObjectFactory/ServiceMapFactory.php b/src/ValueObjectFactory/ServiceMapFactory.php index c110bbbd6..bab945abf 100644 --- a/src/ValueObjectFactory/ServiceMapFactory.php +++ b/src/ValueObjectFactory/ServiceMapFactory.php @@ -148,6 +148,7 @@ private function createAliasServiceDefinitions(array $aliases, array $services): [] ); } + return $services; }