diff --git a/config/sets/symfony/symfony6/symfony-return-types.php b/config/sets/symfony/symfony6/symfony-return-types.php deleted file mode 100644 index ff50c6391..000000000 --- a/config/sets/symfony/symfony6/symfony-return-types.php +++ /dev/null @@ -1,584 +0,0 @@ -newInstanceWithoutConstructor(); - - $privatesAccessor = new PrivatesAccessor(); - $privatesAccessor->setPrivateProperty($scalarArrayObjectUnionType, 'types', $scalarArrayObjectUnionedTypes); - $rectorConfig->ruleWithConfiguration(AddReturnTypeDeclarationRector::class, [ - new AddReturnTypeDeclaration('Symfony\Component\Config\Loader\LoaderInterface', 'load', new MixedType()), - new AddReturnTypeDeclaration('Symfony\Component\Config\Loader\Loader', 'import', new MixedType()), - new AddReturnTypeDeclaration( - 'Symfony\Component\HttpKernel\KernelInterface', - 'registerBundles', - $iterableType, - ), - // @see https://wouterj.nl/2021/09/symfony-6-native-typing#when-upgrading-to-symfony-54 - new AddReturnTypeDeclaration( - 'Symfony\Component\Security\Core\User\UserInterface', - 'getRoles', - new ArrayType(new MixedType(), new MixedType()) - ), - // @see https://github.com/symfony/symfony/pull/43028/files - new AddReturnTypeDeclaration( - 'Symfony\Component\Console\Helper\HelperInterface', - 'getName', - new StringType() - ), - new AddReturnTypeDeclaration( - 'Symfony\Component\BrowserKit\AbstractBrowser', - 'doRequestInProcess', - new ObjectWithoutClassType() - ), - new AddReturnTypeDeclaration( - 'Symfony\Component\BrowserKit\AbstractBrowser', - 'doRequest', - new ObjectWithoutClassType() - ), - new AddReturnTypeDeclaration( - 'Symfony\Component\BrowserKit\AbstractBrowser', - 'filterRequest', - new ObjectWithoutClassType() - ), - new AddReturnTypeDeclaration( - 'Symfony\Component\BrowserKit\AbstractBrowser', - 'filterResponse', - $browserKitResponseType - ), - new AddReturnTypeDeclaration( - 'Symfony\Component\Config\Definition\ConfigurationInterface', - 'getConfigTreeBuilder', - new ObjectType('Symfony\Component\Config\Definition\Builder\TreeBuilder') - ), - new AddReturnTypeDeclaration('Symfony\Component\Config\FileLocator', 'locate', new UnionType([ - new StringType(), - $arrayType, - ])), - new AddReturnTypeDeclaration('Symfony\Component\Config\FileLocatorInterface', 'locate', new UnionType([ - new StringType(), - $arrayType, - ])), - new AddReturnTypeDeclaration('Symfony\Component\Config\Loader\FileLoader', 'import', new MixedType()), - new AddReturnTypeDeclaration('Symfony\Component\Config\Loader\Loader', 'import', new MixedType()), - new AddReturnTypeDeclaration('Symfony\Component\Config\Loader\LoaderInterface', 'load', new MixedType()), - new AddReturnTypeDeclaration( - 'Symfony\Component\Config\Loader\LoaderInterface', - 'supports', - new BooleanType() - ), - new AddReturnTypeDeclaration( - 'Symfony\Component\Config\Loader\LoaderInterface', - 'getResolver', - new ObjectType('Symfony\Component\Config\Loader\LoaderResolverInterface') - ), - new AddReturnTypeDeclaration( - 'Symfony\Component\Config\ResourceCheckerInterface', - 'supports', - new BooleanType() - ), - new AddReturnTypeDeclaration( - 'Symfony\Component\Config\ResourceCheckerInterface', - 'isFresh', - new BooleanType() - ), - new AddReturnTypeDeclaration('Symfony\Component\Console\Application', 'doRun', new IntegerType()), - new AddReturnTypeDeclaration('Symfony\Component\Console\Application', 'getLongVersion', new StringType()), - new AddReturnTypeDeclaration('Symfony\Component\Console\Application', 'add', new UnionType([ - new NullType(), - $commandType, - ])), - new AddReturnTypeDeclaration('Symfony\Component\Console\Application', 'get', $commandType), - new AddReturnTypeDeclaration('Symfony\Component\Console\Application', 'find', $commandType), - new AddReturnTypeDeclaration('Symfony\Component\Console\Application', 'all', $arrayType), - new AddReturnTypeDeclaration('Symfony\Component\Console\Application', 'doRunCommand', new IntegerType()), - new AddReturnTypeDeclaration('Symfony\Component\Console\Command\Command', 'isEnabled', new BooleanType()), - new AddReturnTypeDeclaration('Symfony\Component\Console\Command\Command', 'execute', new IntegerType()), - new AddReturnTypeDeclaration( - 'Symfony\Component\Console\Helper\HelperInterface', - 'getName', - new StringType() - ), - new AddReturnTypeDeclaration( - 'Symfony\Component\Console\Input\InputInterface', - 'getParameterOption', - new MixedType() - ), - new AddReturnTypeDeclaration( - 'Symfony\Component\Console\Input\InputInterface', - 'getArgument', - new MixedType() - ), - new AddReturnTypeDeclaration( - 'Symfony\Component\Console\Input\InputInterface', - 'getOption', - new MixedType() - ), - new AddReturnTypeDeclaration( - 'Symfony\Component\DependencyInjection\Compiler\AbstractRecursivePass', - 'processValue', - new MixedType() - ), - new AddReturnTypeDeclaration( - 'Symfony\Component\DependencyInjection\Extension\ConfigurationExtensionInterface', - 'getConfiguration', - new UnionType([new NullType(), $configurationType]) - ), - new AddReturnTypeDeclaration( - 'Symfony\Component\DependencyInjection\Extension\Extension', - 'getXsdValidationBasePath', - new UnionType([new StringType(), new ConstantBooleanType(false)]) - ), - new AddReturnTypeDeclaration( - 'Symfony\Component\DependencyInjection\Extension\Extension', - 'getNamespace', - new StringType() - ), - new AddReturnTypeDeclaration( - 'Symfony\Component\DependencyInjection\Extension\Extension', - 'getConfiguration', - new UnionType([new NullType(), $configurationType]) - ), - new AddReturnTypeDeclaration( - 'Symfony\Component\DependencyInjection\Extension\ExtensionInterface', - 'getNamespace', - new StringType() - ), - new AddReturnTypeDeclaration( - 'Symfony\Component\DependencyInjection\Extension\ExtensionInterface', - 'getXsdValidationBasePath', - new UnionType([new StringType(), new ConstantBooleanType(false)]) - ), - new AddReturnTypeDeclaration( - 'Symfony\Component\DependencyInjection\Extension\ExtensionInterface', - 'getAlias', - new StringType() - ), - new AddReturnTypeDeclaration( - 'Symfony\Component\DependencyInjection\LazyProxy\Instantiator\InstantiatorInterface', - 'instantiateProxy', - new ObjectWithoutClassType() - ), - new AddReturnTypeDeclaration( - 'Symfony\Component\EventDispatcher\EventSubscriberInterface', - 'getSubscribedEvents', - $arrayType - ), - new AddReturnTypeDeclaration( - 'Symfony\Component\ExpressionLanguage\ExpressionFunctionProviderInterface', - 'getFunctions', - $arrayType - ), - new AddReturnTypeDeclaration('Symfony\Component\Form\AbstractExtension', 'loadTypes', $arrayType), - new AddReturnTypeDeclaration( - 'Symfony\Component\Form\AbstractExtension', - 'loadTypeGuesser', - new UnionType([new NullType(), new ObjectType('Symfony\Component\Form\FormTypeGuesserInterface')]) - ), - new AddReturnTypeDeclaration( - 'Symfony\Component\Form\AbstractRendererEngine', - 'loadResourceForBlockName', - new BooleanType() - ), - new AddReturnTypeDeclaration('Symfony\Component\Form\AbstractType', 'getBlockPrefix', new StringType()), - new AddReturnTypeDeclaration('Symfony\Component\Form\AbstractType', 'getParent', $nullableStringType), - new AddReturnTypeDeclaration( - 'Symfony\Component\Form\DataTransformerInterface', - 'transform', - new MixedType() - ), - new AddReturnTypeDeclaration( - 'Symfony\Component\Form\DataTransformerInterface', - 'reverseTransform', - new MixedType() - ), - new AddReturnTypeDeclaration( - 'Symfony\Component\Form\FormRendererEngineInterface', - 'renderBlock', - new StringType() - ), - new AddReturnTypeDeclaration( - 'Symfony\Component\Form\FormTypeGuesserInterface', - 'guessType', - new UnionType([new NullType(), $typeGuessType]), - ), - new AddReturnTypeDeclaration( - 'Symfony\Component\Form\FormTypeGuesserInterface', - 'guessRequired', - $nullableValueGuessType - ), - new AddReturnTypeDeclaration( - 'Symfony\Component\Form\FormTypeGuesserInterface', - 'guessMaxLength', - $nullableValueGuessType - ), - new AddReturnTypeDeclaration( - 'Symfony\Component\Form\FormTypeGuesserInterface', - 'guessPattern', - $nullableValueGuessType - ), - new AddReturnTypeDeclaration( - 'Symfony\Component\Form\FormTypeInterface', - 'getBlockPrefix', - new StringType() - ), - new AddReturnTypeDeclaration('Symfony\Component\Form\FormTypeInterface', 'getParent', $nullableStringType), - new AddReturnTypeDeclaration('Symfony\Component\Form\FormTypeInterface', 'buildForm', new VoidType()), - new AddReturnTypeDeclaration('Symfony\Component\Form\FormTypeInterface', 'configureOptions', new VoidType()), - new AddReturnTypeDeclaration( - 'Symfony\Component\HttpKernel\CacheWarmer\CacheWarmerInterface', - 'isOptional', - new BooleanType() - ), - new AddReturnTypeDeclaration( - 'Symfony\Component\HttpKernel\CacheWarmer\WarmableInterface', - 'warmUp', - $arrayType - ), - new AddReturnTypeDeclaration( - 'Symfony\Component\HttpKernel\DataCollector\DataCollector', - 'getCasters', - $arrayType - ), - new AddReturnTypeDeclaration( - 'Symfony\Component\HttpKernel\DataCollector\DataCollectorInterface', - 'getName', - new StringType() - ), - new AddReturnTypeDeclaration( - 'Symfony\Component\HttpKernel\HttpCache\HttpCache', - 'forward', - $httpFoundationResponseType - ), - new AddReturnTypeDeclaration( - 'Symfony\Component\HttpKernel\HttpKernelBrowser', - 'doRequest', - $httpFoundationResponseType - ), - new AddReturnTypeDeclaration( - 'Symfony\Component\HttpKernel\HttpKernelBrowser', - 'getScript', - new StringType() - ), - new AddReturnTypeDeclaration( - 'Symfony\Component\HttpKernel\Log\DebugLoggerInterface', - 'getLogs', - $arrayType - ), - new AddReturnTypeDeclaration( - 'Symfony\Component\HttpKernel\Log\DebugLoggerInterface', - 'countErrors', - new IntegerType() - ), - new AddReturnTypeDeclaration( - 'Symfony\Component\OptionsResolver\OptionsResolver', - 'setNormalizer', - new SimpleStaticType('Symfony\Component\OptionsResolver\OptionsResolver') - ), - new AddReturnTypeDeclaration( - 'Symfony\Component\OptionsResolver\OptionsResolver', - 'setAllowedValues', - new SimpleStaticType('Symfony\Component\OptionsResolver\OptionsResolver') - ), - new AddReturnTypeDeclaration( - 'Symfony\Component\OptionsResolver\OptionsResolver', - 'addAllowedValues', - new SimpleStaticType('Symfony\Component\OptionsResolver\OptionsResolver') - ), - new AddReturnTypeDeclaration( - 'Symfony\Component\OptionsResolver\OptionsResolver', - 'setAllowedTypes', - new SimpleStaticType('Symfony\Component\OptionsResolver\OptionsResolver') - ), - new AddReturnTypeDeclaration( - 'Symfony\Component\OptionsResolver\OptionsResolver', - 'addAllowedTypes', - new SimpleStaticType('Symfony\Component\OptionsResolver\OptionsResolver') - ), - new AddReturnTypeDeclaration( - 'Symfony\Component\PropertyAccess\PropertyPathInterface', - 'getLength', - new IntegerType() - ), - new AddReturnTypeDeclaration( - 'Symfony\Component\PropertyAccess\PropertyPathInterface', - 'getParent', - new UnionType([ - new NullType(), - new ObjectType('Symfony\Component\PropertyAccess\PropertyPathInterface'), - ]) - ), - new AddReturnTypeDeclaration( - 'Symfony\Component\PropertyAccess\PropertyPathInterface', - 'getElements', - $arrayType - ), - new AddReturnTypeDeclaration( - 'Symfony\Component\PropertyAccess\PropertyPathInterface', - 'getElement', - new StringType() - ), - new AddReturnTypeDeclaration( - 'Symfony\Component\PropertyAccess\PropertyPathInterface', - 'isProperty', - new BooleanType() - ), - new AddReturnTypeDeclaration( - 'Symfony\Component\PropertyAccess\PropertyPathInterface', - 'isIndex', - new BooleanType() - ), - new AddReturnTypeDeclaration( - 'Symfony\Component\PropertyInfo\PropertyAccessExtractorInterface', - 'isReadable', - $nullableBooleanType - ), - new AddReturnTypeDeclaration( - 'Symfony\Component\PropertyInfo\PropertyAccessExtractorInterface', - 'isWritable', - $nullableBooleanType - ), - new AddReturnTypeDeclaration( - 'Symfony\Component\PropertyInfo\PropertyListExtractorInterface', - 'getProperties', - $nullableArrayType - ), - new AddReturnTypeDeclaration( - 'Symfony\Component\PropertyInfo\PropertyTypeExtractorInterface', - 'getTypes', - $nullableArrayType - ), - new AddReturnTypeDeclaration( - 'Symfony\Component\Routing\Loader\AnnotationClassLoader', - 'getDefaultRouteName', - new StringType() - ), - new AddReturnTypeDeclaration( - 'Symfony\Component\Routing\Router', - 'getRouteCollection', - $routeCollectionType - ), - new AddReturnTypeDeclaration( - 'Symfony\Component\Routing\RouterInterface', - 'getRouteCollection', - $routeCollectionType - ), - new AddReturnTypeDeclaration( - 'Symfony\Component\Security\Core\Authentication\RememberMe\TokenProviderInterface', - 'loadTokenBySeries', - new ObjectType('Symfony\Component\Security\Core\Authentication\RememberMe\PersistentTokenInterface') - ), - new AddReturnTypeDeclaration( - 'Symfony\Component\Security\Core\Authorization\Voter\VoterInterface', - 'vote', - new IntegerType() - ), - new AddReturnTypeDeclaration( - 'Symfony\Component\Security\Core\Exception\AuthenticationException', - 'getMessageKey', - new StringType() - ), - new AddReturnTypeDeclaration( - 'Symfony\Component\Security\Core\User\UserProviderInterface', - 'refreshUser', - new ObjectType('Symfony\Component\Security\Core\User\UserInterface') - ), - new AddReturnTypeDeclaration( - 'Symfony\Component\Security\Core\User\UserProviderInterface', - 'supportsClass', - new BooleanType() - ), - new AddReturnTypeDeclaration( - 'Symfony\Component\Security\Http\EntryPoint\AuthenticationEntryPointInterface', - 'start', - $httpFoundationResponseType - ), - new AddReturnTypeDeclaration('Symfony\Component\Security\Http\Firewall', 'getSubscribedEvents', $arrayType), - new AddReturnTypeDeclaration( - 'Symfony\Component\Security\Http\FirewallMapInterface', - 'getListeners', - $arrayType - ), - new AddReturnTypeDeclaration( - 'Symfony\Component\Serializer\Encoder\DecoderInterface', - 'decode', - new MixedType() - ), - new AddReturnTypeDeclaration( - 'Symfony\Component\Serializer\Encoder\DecoderInterface', - 'supportsDecoding', - new BooleanType() - ), - new AddReturnTypeDeclaration( - 'Symfony\Component\Serializer\Normalizer\AbstractNormalizer', - 'getAllowedAttributes', - new UnionType([$arrayType, new BooleanType()]) - ), - new AddReturnTypeDeclaration( - 'Symfony\Component\Serializer\Normalizer\AbstractNormalizer', - 'isAllowedAttribute', - new BooleanType() - ), - new AddReturnTypeDeclaration( - 'Symfony\Component\Serializer\Normalizer\AbstractNormalizer', - 'instantiateObject', - new ObjectWithoutClassType() - ), - new AddReturnTypeDeclaration( - 'Symfony\Component\Serializer\Normalizer\AbstractObjectNormalizer', - 'supportsNormalization', - new BooleanType() - ), - - new AddReturnTypeDeclaration( - 'Symfony\Component\Serializer\Normalizer\AbstractObjectNormalizer', - 'instantiateObject', - new ObjectWithoutClassType() - ), - new AddReturnTypeDeclaration( - 'Symfony\Component\Serializer\Normalizer\AbstractObjectNormalizer', - 'extractAttributes', - $arrayType - ), - new AddReturnTypeDeclaration( - 'Symfony\Component\Serializer\Normalizer\AbstractObjectNormalizer', - 'getAttributeValue', - new MixedType() - ), - new AddReturnTypeDeclaration( - 'Symfony\Component\Serializer\Normalizer\AbstractObjectNormalizer', - 'supportsDenormalization', - new BooleanType() - ), - new AddReturnTypeDeclaration( - 'Symfony\Component\Serializer\Normalizer\AbstractObjectNormalizer', - 'denormalize', - new MixedType() - ), - new AddReturnTypeDeclaration( - 'Symfony\Component\Serializer\Normalizer\DenormalizerInterface', - 'denormalize', - new MixedType() - ), - new AddReturnTypeDeclaration( - 'Symfony\Component\Serializer\Normalizer\DenormalizerInterface', - 'supportsDenormalization', - new BooleanType() - ), - new AddReturnTypeDeclaration( - 'Symfony\Component\Serializer\Normalizer\NormalizerInterface', - 'supportsNormalization', - new BooleanType() - ), - new AddReturnTypeDeclaration( - 'Symfony\Component\Templating\Helper\HelperInterface', - 'getName', - new StringType() - ), - new AddReturnTypeDeclaration( - 'Symfony\Component\Translation\Extractor\AbstractFileExtractor', - 'canBeExtracted', - new BooleanType() - ), - new AddReturnTypeDeclaration( - 'Symfony\Component\Translation\Extractor\AbstractFileExtractor', - 'extractFromDirectory', - $iterableType - ), - new AddReturnTypeDeclaration( - 'Symfony\Component\Validator\Constraint', - 'getDefaultOption', - $nullableStringType - ), - new AddReturnTypeDeclaration('Symfony\Component\Validator\Constraint', 'getRequiredOptions', $arrayType), - new AddReturnTypeDeclaration('Symfony\Component\Validator\Constraint', 'validatedBy', new StringType()), - new AddReturnTypeDeclaration( - 'Symfony\Component\Validator\Constraint', - 'getTargets', - new UnionType([new StringType(), $arrayType]) - ), - - new AddReturnTypeDeclaration( - 'Symfony\Component\Serializer\Normalizer\AbstractObjectNormalizer', - 'normalize', - $scalarArrayObjectUnionType - ), - new AddReturnTypeDeclaration( - 'Symfony\Component\DependencyInjection\Container', - 'getParameter', - new UnionType($scalarTypes) - ), - new AddReturnTypeDeclaration( - 'Symfony\Component\DependencyInjection\ContainerInterface', - 'getParameter', - new UnionType($scalarTypes) - ), - new AddReturnTypeDeclaration( - 'Symfony\Component\Serializer\Normalizer\NormalizerInterface', - 'normalize', - $scalarArrayObjectUnionType - ), - new AddReturnTypeDeclaration( - 'Symfony\Component\Security\Http\Authenticator\AuthenticatorInterface', - 'authenticate', - new ObjectType('Symfony\Component\Security\Http\Authenticator\Passport\Passport') - ), - ]); -}; diff --git a/config/sets/symfony/symfony6/symfony60.php b/config/sets/symfony/symfony6/symfony60.php index e80bde6db..5f71659a0 100644 --- a/config/sets/symfony/symfony6/symfony60.php +++ b/config/sets/symfony/symfony6/symfony60.php @@ -9,8 +9,21 @@ return static function (RectorConfig $rectorConfig): void { // $rectorConfig->sets([SymfonySetList::ANNOTATIONS_TO_ATTRIBUTES]); - $rectorConfig->import(__DIR__ . '/symfony-return-types.php'); // todo: extract this as well - + $rectorConfig->import(__DIR__ . '/symfony60/symfony60-serializer.php'); + $rectorConfig->import(__DIR__ . '/symfony60/symfony60-security-http.php'); + $rectorConfig->import(__DIR__ . '/symfony60/symfony60-console.php'); + $rectorConfig->import(__DIR__ . '/symfony60/symfony60-browser-kit.php'); + $rectorConfig->import(__DIR__ . '/symfony60/symfony60-http-kernel.php'); + $rectorConfig->import(__DIR__ . '/symfony60/symfony60-validator.php'); + $rectorConfig->import(__DIR__ . '/symfony60/symfony60-form.php'); + $rectorConfig->import(__DIR__ . '/symfony60/symfony60-translation.php'); + $rectorConfig->import(__DIR__ . '/symfony60/symfony60-property-access.php'); + $rectorConfig->import(__DIR__ . '/symfony60/symfony60-property-info.php'); + $rectorConfig->import(__DIR__ . '/symfony60/symfony60-routing.php'); + $rectorConfig->import(__DIR__ . '/symfony60/symfony60-templating.php'); + $rectorConfig->import(__DIR__ . '/symfony60/symfony60-event-dispatcher.php'); + $rectorConfig->import(__DIR__ . '/symfony60/symfony60-expression-language.php'); + $rectorConfig->import(__DIR__ . '/symfony60/symfony60-options-resolver.php'); $rectorConfig->import(__DIR__ . '/symfony60/symfony60-dependency-injection.php'); $rectorConfig->import(__DIR__ . '/symfony60/symfony60-contracts.php'); $rectorConfig->import(__DIR__ . '/symfony60/symfony60-config.php'); diff --git a/config/sets/symfony/symfony6/symfony60/symfony60-browser-kit.php b/config/sets/symfony/symfony6/symfony60/symfony60-browser-kit.php new file mode 100644 index 000000000..ec6fde0c9 --- /dev/null +++ b/config/sets/symfony/symfony6/symfony60/symfony60-browser-kit.php @@ -0,0 +1,38 @@ +ruleWithConfiguration(AddReturnTypeDeclarationRector::class, [ + new AddReturnTypeDeclaration( + 'Symfony\Component\BrowserKit\AbstractBrowser', + 'doRequestInProcess', + new ObjectWithoutClassType() + ), + new AddReturnTypeDeclaration( + 'Symfony\Component\BrowserKit\AbstractBrowser', + 'doRequest', + new ObjectWithoutClassType() + ), + new AddReturnTypeDeclaration( + 'Symfony\Component\BrowserKit\AbstractBrowser', + 'filterRequest', + new ObjectWithoutClassType() + ), + new AddReturnTypeDeclaration( + 'Symfony\Component\BrowserKit\AbstractBrowser', + 'filterResponse', + $browserKitResponseType + ), + ]); +}; diff --git a/config/sets/symfony/symfony6/symfony60/symfony60-config.php b/config/sets/symfony/symfony6/symfony60/symfony60-config.php index a954aa5b3..ccfcbb5f5 100644 --- a/config/sets/symfony/symfony6/symfony60/symfony60-config.php +++ b/config/sets/symfony/symfony6/symfony60/symfony60-config.php @@ -5,7 +5,14 @@ use PHPStan\Type\MixedType; use Rector\Config\RectorConfig; use Rector\TypeDeclaration\Rector\ClassMethod\AddParamTypeDeclarationRector; +use Rector\TypeDeclaration\Rector\ClassMethod\AddReturnTypeDeclarationRector; use Rector\TypeDeclaration\ValueObject\AddParamTypeDeclaration; +use Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration; +use PHPStan\Type\BooleanType; +use PHPStan\Type\ObjectType; +use PHPStan\Type\StringType; +use PHPStan\Type\UnionType; +use PHPStan\Type\ArrayType; return static function (RectorConfig $rectorConfig): void { $rectorConfig->ruleWithConfiguration(AddParamTypeDeclarationRector::class, [ @@ -22,4 +29,47 @@ new MixedType(true) ), ]); + + $arrayType = new ArrayType(new MixedType(), new MixedType()); + + $rectorConfig->ruleWithConfiguration(AddReturnTypeDeclarationRector::class, [ + new AddReturnTypeDeclaration('Symfony\Component\Config\Loader\LoaderInterface', 'load', new MixedType()), + new AddReturnTypeDeclaration('Symfony\Component\Config\Loader\Loader', 'import', new MixedType()), + new AddReturnTypeDeclaration( + 'Symfony\Component\Config\Definition\ConfigurationInterface', + 'getConfigTreeBuilder', + new ObjectType('Symfony\Component\Config\Definition\Builder\TreeBuilder') + ), + new AddReturnTypeDeclaration('Symfony\Component\Config\FileLocator', 'locate', new UnionType([ + new StringType(), + $arrayType, + ])), + new AddReturnTypeDeclaration('Symfony\Component\Config\FileLocatorInterface', 'locate', new UnionType([ + new StringType(), + $arrayType, + ])), + new AddReturnTypeDeclaration('Symfony\Component\Config\Loader\FileLoader', 'import', new MixedType()), + new AddReturnTypeDeclaration('Symfony\Component\Config\Loader\Loader', 'import', new MixedType()), + new AddReturnTypeDeclaration('Symfony\Component\Config\Loader\LoaderInterface', 'load', new MixedType()), + new AddReturnTypeDeclaration( + 'Symfony\Component\Config\Loader\LoaderInterface', + 'supports', + new BooleanType() + ), + new AddReturnTypeDeclaration( + 'Symfony\Component\Config\Loader\LoaderInterface', + 'getResolver', + new ObjectType('Symfony\Component\Config\Loader\LoaderResolverInterface') + ), + new AddReturnTypeDeclaration( + 'Symfony\Component\Config\ResourceCheckerInterface', + 'supports', + new BooleanType() + ), + new AddReturnTypeDeclaration( + 'Symfony\Component\Config\ResourceCheckerInterface', + 'isFresh', + new BooleanType() + ), + ]); }; diff --git a/config/sets/symfony/symfony6/symfony60/symfony60-console.php b/config/sets/symfony/symfony6/symfony60/symfony60-console.php new file mode 100644 index 000000000..a34619fd1 --- /dev/null +++ b/config/sets/symfony/symfony6/symfony60/symfony60-console.php @@ -0,0 +1,65 @@ +ruleWithConfiguration(AddReturnTypeDeclarationRector::class, [ + // @see https://github.com/symfony/symfony/pull/43028/files + new AddReturnTypeDeclaration( + 'Symfony\Component\Console\Helper\HelperInterface', + 'getName', + new StringType() + ), + + new AddReturnTypeDeclaration('Symfony\Component\Console\Application', 'doRun', new IntegerType()), + new AddReturnTypeDeclaration('Symfony\Component\Console\Application', 'getLongVersion', new StringType()), + new AddReturnTypeDeclaration('Symfony\Component\Console\Application', 'add', new UnionType([ + new NullType(), + $commandType, + ])), + new AddReturnTypeDeclaration('Symfony\Component\Console\Application', 'get', $commandType), + new AddReturnTypeDeclaration('Symfony\Component\Console\Application', 'find', $commandType), + new AddReturnTypeDeclaration('Symfony\Component\Console\Application', 'all', $arrayType), + new AddReturnTypeDeclaration('Symfony\Component\Console\Application', 'doRunCommand', new IntegerType()), + new AddReturnTypeDeclaration('Symfony\Component\Console\Command\Command', 'isEnabled', new BooleanType()), + new AddReturnTypeDeclaration('Symfony\Component\Console\Command\Command', 'execute', new IntegerType()), + new AddReturnTypeDeclaration( + 'Symfony\Component\Console\Helper\HelperInterface', + 'getName', + new StringType() + ), + new AddReturnTypeDeclaration( + 'Symfony\Component\Console\Input\InputInterface', + 'getParameterOption', + new MixedType() + ), + new AddReturnTypeDeclaration( + 'Symfony\Component\Console\Input\InputInterface', + 'getArgument', + new MixedType() + ), + new AddReturnTypeDeclaration( + 'Symfony\Component\Console\Input\InputInterface', + 'getOption', + new MixedType() + ), + ]); +}; diff --git a/config/sets/symfony/symfony6/symfony60/symfony60-dependency-injection.php b/config/sets/symfony/symfony6/symfony60/symfony60-dependency-injection.php index 4bf9cdd97..e93555f6d 100644 --- a/config/sets/symfony/symfony6/symfony60/symfony60-dependency-injection.php +++ b/config/sets/symfony/symfony6/symfony60/symfony60-dependency-injection.php @@ -6,6 +6,19 @@ use Rector\Config\RectorConfig; use Rector\Symfony\Symfony60\Rector\FuncCall\ReplaceServiceArgumentRector; use Rector\Symfony\ValueObject\ReplaceServiceArgument; +use Rector\TypeDeclaration\Rector\ClassMethod\AddReturnTypeDeclarationRector; +use Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration; +use PHPStan\Type\Constant\ConstantBooleanType; +use PHPStan\Type\MixedType; +use PHPStan\Type\NullType; +use PHPStan\Type\ObjectType; +use PHPStan\Type\ObjectWithoutClassType; +use PHPStan\Type\StringType; +use PHPStan\Type\UnionType; +use PHPStan\Type\ArrayType; +use PHPStan\Type\BooleanType; +use PHPStan\Type\FloatType; +use PHPStan\Type\IntegerType; return static function (RectorConfig $rectorConfig): void { $rectorConfig->ruleWithConfiguration(ReplaceServiceArgumentRector::class, [ @@ -15,4 +28,74 @@ new String_('service_container') ), ]); + + $configurationType = new ObjectType('Symfony\Component\Config\Definition\ConfigurationInterface'); + + $arrayType = new ArrayType(new MixedType(), new MixedType()); + $scalarTypes = [ + $arrayType, + new BooleanType(), + new StringType(), + new IntegerType(), + new FloatType(), + new NullType(), + ]; + + $rectorConfig->ruleWithConfiguration(AddReturnTypeDeclarationRector::class, [ + new AddReturnTypeDeclaration( + 'Symfony\Component\DependencyInjection\Compiler\AbstractRecursivePass', + 'processValue', + new MixedType() + ), + new AddReturnTypeDeclaration( + 'Symfony\Component\DependencyInjection\Extension\ConfigurationExtensionInterface', + 'getConfiguration', + new UnionType([new NullType(), $configurationType]) + ), + new AddReturnTypeDeclaration( + 'Symfony\Component\DependencyInjection\Extension\Extension', + 'getXsdValidationBasePath', + new UnionType([new StringType(), new ConstantBooleanType(false)]) + ), + new AddReturnTypeDeclaration( + 'Symfony\Component\DependencyInjection\Extension\Extension', + 'getNamespace', + new StringType() + ), + new AddReturnTypeDeclaration( + 'Symfony\Component\DependencyInjection\Extension\Extension', + 'getConfiguration', + new UnionType([new NullType(), $configurationType]) + ), + new AddReturnTypeDeclaration( + 'Symfony\Component\DependencyInjection\Extension\ExtensionInterface', + 'getNamespace', + new StringType() + ), + new AddReturnTypeDeclaration( + 'Symfony\Component\DependencyInjection\Extension\ExtensionInterface', + 'getXsdValidationBasePath', + new UnionType([new StringType(), new ConstantBooleanType(false)]) + ), + new AddReturnTypeDeclaration( + 'Symfony\Component\DependencyInjection\Extension\ExtensionInterface', + 'getAlias', + new StringType() + ), + new AddReturnTypeDeclaration( + 'Symfony\Component\DependencyInjection\LazyProxy\Instantiator\InstantiatorInterface', + 'instantiateProxy', + new ObjectWithoutClassType() + ), + new AddReturnTypeDeclaration( + 'Symfony\Component\DependencyInjection\Container', + 'getParameter', + new UnionType($scalarTypes) + ), + new AddReturnTypeDeclaration( + 'Symfony\Component\DependencyInjection\ContainerInterface', + 'getParameter', + new UnionType($scalarTypes) + ), + ]); }; diff --git a/config/sets/symfony/symfony6/symfony60/symfony60-event-dispatcher.php b/config/sets/symfony/symfony6/symfony60/symfony60-event-dispatcher.php new file mode 100644 index 000000000..e44144aca --- /dev/null +++ b/config/sets/symfony/symfony6/symfony60/symfony60-event-dispatcher.php @@ -0,0 +1,24 @@ +ruleWithConfiguration(AddReturnTypeDeclarationRector::class, [ + new AddReturnTypeDeclaration( + 'Symfony\Component\EventDispatcher\EventSubscriberInterface', + 'getSubscribedEvents', + $arrayType + ), + ]); +}; diff --git a/config/sets/symfony/symfony6/symfony60/symfony60-expression-language.php b/config/sets/symfony/symfony6/symfony60/symfony60-expression-language.php new file mode 100644 index 000000000..6ef58ad27 --- /dev/null +++ b/config/sets/symfony/symfony6/symfony60/symfony60-expression-language.php @@ -0,0 +1,24 @@ +ruleWithConfiguration(AddReturnTypeDeclarationRector::class, [ + new AddReturnTypeDeclaration( + 'Symfony\Component\ExpressionLanguage\ExpressionFunctionProviderInterface', + 'getFunctions', + $arrayType + ), + ]); +}; diff --git a/config/sets/symfony/symfony6/symfony60/symfony60-form.php b/config/sets/symfony/symfony6/symfony60/symfony60-form.php new file mode 100644 index 000000000..21c887093 --- /dev/null +++ b/config/sets/symfony/symfony6/symfony60/symfony60-form.php @@ -0,0 +1,88 @@ +ruleWithConfiguration(AddReturnTypeDeclarationRector::class, [ + new AddReturnTypeDeclaration('Symfony\Component\Form\AbstractExtension', 'loadTypes', $arrayType), + new AddReturnTypeDeclaration( + 'Symfony\Component\Form\AbstractExtension', + 'loadTypeGuesser', + new UnionType([new NullType(), new ObjectType('Symfony\Component\Form\FormTypeGuesserInterface')]) + ), + new AddReturnTypeDeclaration( + 'Symfony\Component\Form\AbstractRendererEngine', + 'loadResourceForBlockName', + new BooleanType() + ), + new AddReturnTypeDeclaration('Symfony\Component\Form\AbstractType', 'getBlockPrefix', new StringType()), + new AddReturnTypeDeclaration('Symfony\Component\Form\AbstractType', 'getParent', $nullableStringType), + new AddReturnTypeDeclaration( + 'Symfony\Component\Form\DataTransformerInterface', + 'transform', + new MixedType() + ), + new AddReturnTypeDeclaration( + 'Symfony\Component\Form\DataTransformerInterface', + 'reverseTransform', + new MixedType() + ), + new AddReturnTypeDeclaration( + 'Symfony\Component\Form\FormRendererEngineInterface', + 'renderBlock', + new StringType() + ), + new AddReturnTypeDeclaration( + 'Symfony\Component\Form\FormTypeGuesserInterface', + 'guessType', + new UnionType([new NullType(), $typeGuessType]), + ), + new AddReturnTypeDeclaration( + 'Symfony\Component\Form\FormTypeGuesserInterface', + 'guessRequired', + $nullableValueGuessType + ), + new AddReturnTypeDeclaration( + 'Symfony\Component\Form\FormTypeGuesserInterface', + 'guessMaxLength', + $nullableValueGuessType + ), + new AddReturnTypeDeclaration( + 'Symfony\Component\Form\FormTypeGuesserInterface', + 'guessPattern', + $nullableValueGuessType + ), + new AddReturnTypeDeclaration( + 'Symfony\Component\Form\FormTypeInterface', + 'getBlockPrefix', + new StringType() + ), + new AddReturnTypeDeclaration('Symfony\Component\Form\FormTypeInterface', 'getParent', $nullableStringType), + new AddReturnTypeDeclaration('Symfony\Component\Form\FormTypeInterface', 'buildForm', new VoidType()), + new AddReturnTypeDeclaration('Symfony\Component\Form\FormTypeInterface', 'configureOptions', new VoidType()), + ]); +}; diff --git a/config/sets/symfony/symfony6/symfony60/symfony60-http-kernel.php b/config/sets/symfony/symfony6/symfony60/symfony60-http-kernel.php new file mode 100644 index 000000000..e60bbeee7 --- /dev/null +++ b/config/sets/symfony/symfony6/symfony60/symfony60-http-kernel.php @@ -0,0 +1,76 @@ +ruleWithConfiguration(AddReturnTypeDeclarationRector::class, [ + new AddReturnTypeDeclaration( + 'Symfony\Component\HttpKernel\KernelInterface', + 'registerBundles', + $iterableType, + ), + new AddReturnTypeDeclaration( + 'Symfony\Component\HttpKernel\CacheWarmer\CacheWarmerInterface', + 'isOptional', + new BooleanType() + ), + new AddReturnTypeDeclaration( + 'Symfony\Component\HttpKernel\CacheWarmer\WarmableInterface', + 'warmUp', + $arrayType + ), + new AddReturnTypeDeclaration( + 'Symfony\Component\HttpKernel\DataCollector\DataCollector', + 'getCasters', + $arrayType + ), + new AddReturnTypeDeclaration( + 'Symfony\Component\HttpKernel\DataCollector\DataCollectorInterface', + 'getName', + new StringType() + ), + new AddReturnTypeDeclaration( + 'Symfony\Component\HttpKernel\HttpCache\HttpCache', + 'forward', + $httpFoundationResponseType + ), + new AddReturnTypeDeclaration( + 'Symfony\Component\HttpKernel\HttpKernelBrowser', + 'doRequest', + $httpFoundationResponseType + ), + new AddReturnTypeDeclaration( + 'Symfony\Component\HttpKernel\HttpKernelBrowser', + 'getScript', + new StringType() + ), + new AddReturnTypeDeclaration( + 'Symfony\Component\HttpKernel\Log\DebugLoggerInterface', + 'getLogs', + $arrayType + ), + new AddReturnTypeDeclaration( + 'Symfony\Component\HttpKernel\Log\DebugLoggerInterface', + 'countErrors', + new IntegerType() + ), + ]); +}; diff --git a/config/sets/symfony/symfony6/symfony60/symfony60-options-resolver.php b/config/sets/symfony/symfony6/symfony60/symfony60-options-resolver.php new file mode 100644 index 000000000..a8642d0cc --- /dev/null +++ b/config/sets/symfony/symfony6/symfony60/symfony60-options-resolver.php @@ -0,0 +1,41 @@ +ruleWithConfiguration(AddReturnTypeDeclarationRector::class, [ + new AddReturnTypeDeclaration( + 'Symfony\Component\OptionsResolver\OptionsResolver', + 'setNormalizer', + new SimpleStaticType('Symfony\Component\OptionsResolver\OptionsResolver') + ), + new AddReturnTypeDeclaration( + 'Symfony\Component\OptionsResolver\OptionsResolver', + 'setAllowedValues', + new SimpleStaticType('Symfony\Component\OptionsResolver\OptionsResolver') + ), + new AddReturnTypeDeclaration( + 'Symfony\Component\OptionsResolver\OptionsResolver', + 'addAllowedValues', + new SimpleStaticType('Symfony\Component\OptionsResolver\OptionsResolver') + ), + new AddReturnTypeDeclaration( + 'Symfony\Component\OptionsResolver\OptionsResolver', + 'setAllowedTypes', + new SimpleStaticType('Symfony\Component\OptionsResolver\OptionsResolver') + ), + new AddReturnTypeDeclaration( + 'Symfony\Component\OptionsResolver\OptionsResolver', + 'addAllowedTypes', + new SimpleStaticType('Symfony\Component\OptionsResolver\OptionsResolver') + ), + ]); +}; diff --git a/config/sets/symfony/symfony6/symfony60/symfony60-property-access.php b/config/sets/symfony/symfony6/symfony60/symfony60-property-access.php new file mode 100644 index 000000000..a915ee7e6 --- /dev/null +++ b/config/sets/symfony/symfony6/symfony60/symfony60-property-access.php @@ -0,0 +1,58 @@ +ruleWithConfiguration(AddReturnTypeDeclarationRector::class, [ + new AddReturnTypeDeclaration( + 'Symfony\Component\PropertyAccess\PropertyPathInterface', + 'getLength', + new IntegerType() + ), + new AddReturnTypeDeclaration( + 'Symfony\Component\PropertyAccess\PropertyPathInterface', + 'getParent', + new UnionType([ + new NullType(), + new ObjectType('Symfony\Component\PropertyAccess\PropertyPathInterface'), + ]) + ), + new AddReturnTypeDeclaration( + 'Symfony\Component\PropertyAccess\PropertyPathInterface', + 'getElements', + $arrayType + ), + new AddReturnTypeDeclaration( + 'Symfony\Component\PropertyAccess\PropertyPathInterface', + 'getElement', + new StringType() + ), + new AddReturnTypeDeclaration( + 'Symfony\Component\PropertyAccess\PropertyPathInterface', + 'isProperty', + new BooleanType() + ), + new AddReturnTypeDeclaration( + 'Symfony\Component\PropertyAccess\PropertyPathInterface', + 'isIndex', + new BooleanType() + ), + ]); +}; diff --git a/config/sets/symfony/symfony6/symfony60/symfony60-property-info.php b/config/sets/symfony/symfony6/symfony60/symfony60-property-info.php new file mode 100644 index 000000000..48fb6d660 --- /dev/null +++ b/config/sets/symfony/symfony6/symfony60/symfony60-property-info.php @@ -0,0 +1,45 @@ +ruleWithConfiguration(AddReturnTypeDeclarationRector::class, [ + new AddReturnTypeDeclaration( + 'Symfony\Component\PropertyInfo\PropertyAccessExtractorInterface', + 'isReadable', + $nullableBooleanType + ), + new AddReturnTypeDeclaration( + 'Symfony\Component\PropertyInfo\PropertyAccessExtractorInterface', + 'isWritable', + $nullableBooleanType + ), + new AddReturnTypeDeclaration( + 'Symfony\Component\PropertyInfo\PropertyListExtractorInterface', + 'getProperties', + $nullableArrayType + ), + new AddReturnTypeDeclaration( + 'Symfony\Component\PropertyInfo\PropertyTypeExtractorInterface', + 'getTypes', + $nullableArrayType + ), + ]); +}; diff --git a/config/sets/symfony/symfony6/symfony60/symfony60-routing.php b/config/sets/symfony/symfony6/symfony60/symfony60-routing.php new file mode 100644 index 000000000..7459c6249 --- /dev/null +++ b/config/sets/symfony/symfony6/symfony60/symfony60-routing.php @@ -0,0 +1,34 @@ +ruleWithConfiguration(AddReturnTypeDeclarationRector::class, [ + new AddReturnTypeDeclaration( + 'Symfony\Component\Routing\Loader\AnnotationClassLoader', + 'getDefaultRouteName', + new StringType() + ), + new AddReturnTypeDeclaration( + 'Symfony\Component\Routing\Router', + 'getRouteCollection', + $routeCollectionType + ), + new AddReturnTypeDeclaration( + 'Symfony\Component\Routing\RouterInterface', + 'getRouteCollection', + $routeCollectionType + ), + ]); +}; diff --git a/config/sets/symfony/symfony6/symfony60/symfony60-security-core.php b/config/sets/symfony/symfony6/symfony60/symfony60-security-core.php index 8e745abf1..796a9ddf6 100644 --- a/config/sets/symfony/symfony6/symfony60/symfony60-security-core.php +++ b/config/sets/symfony/symfony6/symfony60/symfony60-security-core.php @@ -5,6 +5,14 @@ use Rector\Config\RectorConfig; use Rector\Renaming\Rector\MethodCall\RenameMethodRector; use Rector\Renaming\ValueObject\MethodCallRename; +use Rector\TypeDeclaration\Rector\ClassMethod\AddReturnTypeDeclarationRector; +use Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration; +use PHPStan\Type\ArrayType; +use PHPStan\Type\BooleanType; +use PHPStan\Type\IntegerType; +use PHPStan\Type\MixedType; +use PHPStan\Type\ObjectType; +use PHPStan\Type\StringType; return static function (RectorConfig $rectorConfig): void { $rectorConfig->ruleWithConfiguration(RenameMethodRector::class, [ @@ -20,4 +28,39 @@ 'getUserIdentifier', ), ]); + + $rectorConfig->ruleWithConfiguration(AddReturnTypeDeclarationRector::class, [ + // @see https://wouterj.nl/2021/09/symfony-6-native-typing#when-upgrading-to-symfony-54 + new AddReturnTypeDeclaration( + 'Symfony\Component\Security\Core\User\UserInterface', + 'getRoles', + new ArrayType(new MixedType(), new MixedType()) + ), + + new AddReturnTypeDeclaration( + 'Symfony\Component\Security\Core\Authentication\RememberMe\TokenProviderInterface', + 'loadTokenBySeries', + new ObjectType('Symfony\Component\Security\Core\Authentication\RememberMe\PersistentTokenInterface') + ), + new AddReturnTypeDeclaration( + 'Symfony\Component\Security\Core\Authorization\Voter\VoterInterface', + 'vote', + new IntegerType() + ), + new AddReturnTypeDeclaration( + 'Symfony\Component\Security\Core\Exception\AuthenticationException', + 'getMessageKey', + new StringType() + ), + new AddReturnTypeDeclaration( + 'Symfony\Component\Security\Core\User\UserProviderInterface', + 'refreshUser', + new ObjectType('Symfony\Component\Security\Core\User\UserInterface') + ), + new AddReturnTypeDeclaration( + 'Symfony\Component\Security\Core\User\UserProviderInterface', + 'supportsClass', + new BooleanType() + ), + ]); }; diff --git a/config/sets/symfony/symfony6/symfony60/symfony60-security-http.php b/config/sets/symfony/symfony6/symfony60/symfony60-security-http.php new file mode 100644 index 000000000..2433a5782 --- /dev/null +++ b/config/sets/symfony/symfony6/symfony60/symfony60-security-http.php @@ -0,0 +1,37 @@ +ruleWithConfiguration(AddReturnTypeDeclarationRector::class, [ + new AddReturnTypeDeclaration( + 'Symfony\Component\Security\Http\EntryPoint\AuthenticationEntryPointInterface', + 'start', + $httpFoundationResponseType + ), + new AddReturnTypeDeclaration('Symfony\Component\Security\Http\Firewall', 'getSubscribedEvents', $arrayType), + new AddReturnTypeDeclaration( + 'Symfony\Component\Security\Http\FirewallMapInterface', + 'getListeners', + $arrayType + ), + new AddReturnTypeDeclaration( + 'Symfony\Component\Security\Http\Authenticator\AuthenticatorInterface', + 'authenticate', + new ObjectType('Symfony\Component\Security\Http\Authenticator\Passport\Passport') + ), + ]); +}; diff --git a/config/sets/symfony/symfony6/symfony60/symfony60-serializer.php b/config/sets/symfony/symfony6/symfony60/symfony60-serializer.php new file mode 100644 index 000000000..abc63fdf1 --- /dev/null +++ b/config/sets/symfony/symfony6/symfony60/symfony60-serializer.php @@ -0,0 +1,128 @@ +newInstanceWithoutConstructor(); + + $privatesAccessor = new PrivatesAccessor(); + $privatesAccessor->setPrivateProperty($scalarArrayObjectUnionType, 'types', $scalarArrayObjectUnionedTypes); + $rectorConfig->ruleWithConfiguration(AddReturnTypeDeclarationRector::class, [ + new AddReturnTypeDeclaration( + 'Symfony\Component\Serializer\Encoder\DecoderInterface', + 'decode', + new MixedType() + ), + new AddReturnTypeDeclaration( + 'Symfony\Component\Serializer\Encoder\DecoderInterface', + 'supportsDecoding', + new BooleanType() + ), + new AddReturnTypeDeclaration( + 'Symfony\Component\Serializer\Normalizer\AbstractNormalizer', + 'getAllowedAttributes', + new UnionType([$arrayType, new BooleanType()]) + ), + new AddReturnTypeDeclaration( + 'Symfony\Component\Serializer\Normalizer\AbstractNormalizer', + 'isAllowedAttribute', + new BooleanType() + ), + new AddReturnTypeDeclaration( + 'Symfony\Component\Serializer\Normalizer\AbstractNormalizer', + 'instantiateObject', + new ObjectWithoutClassType() + ), + new AddReturnTypeDeclaration( + 'Symfony\Component\Serializer\Normalizer\AbstractObjectNormalizer', + 'supportsNormalization', + new BooleanType() + ), + + new AddReturnTypeDeclaration( + 'Symfony\Component\Serializer\Normalizer\AbstractObjectNormalizer', + 'instantiateObject', + new ObjectWithoutClassType() + ), + new AddReturnTypeDeclaration( + 'Symfony\Component\Serializer\Normalizer\AbstractObjectNormalizer', + 'extractAttributes', + $arrayType + ), + new AddReturnTypeDeclaration( + 'Symfony\Component\Serializer\Normalizer\AbstractObjectNormalizer', + 'getAttributeValue', + new MixedType() + ), + new AddReturnTypeDeclaration( + 'Symfony\Component\Serializer\Normalizer\AbstractObjectNormalizer', + 'supportsDenormalization', + new BooleanType() + ), + new AddReturnTypeDeclaration( + 'Symfony\Component\Serializer\Normalizer\AbstractObjectNormalizer', + 'denormalize', + new MixedType() + ), + new AddReturnTypeDeclaration( + 'Symfony\Component\Serializer\Normalizer\DenormalizerInterface', + 'denormalize', + new MixedType() + ), + new AddReturnTypeDeclaration( + 'Symfony\Component\Serializer\Normalizer\DenormalizerInterface', + 'supportsDenormalization', + new BooleanType() + ), + new AddReturnTypeDeclaration( + 'Symfony\Component\Serializer\Normalizer\NormalizerInterface', + 'supportsNormalization', + new BooleanType() + ), + new AddReturnTypeDeclaration( + 'Symfony\Component\Serializer\Normalizer\AbstractObjectNormalizer', + 'normalize', + $scalarArrayObjectUnionType + ), + new AddReturnTypeDeclaration( + 'Symfony\Component\Serializer\Normalizer\NormalizerInterface', + 'normalize', + $scalarArrayObjectUnionType + ), + ]); +}; diff --git a/config/sets/symfony/symfony6/symfony60/symfony60-templating.php b/config/sets/symfony/symfony6/symfony60/symfony60-templating.php new file mode 100644 index 000000000..2620badb0 --- /dev/null +++ b/config/sets/symfony/symfony6/symfony60/symfony60-templating.php @@ -0,0 +1,21 @@ +ruleWithConfiguration(AddReturnTypeDeclarationRector::class, [ + new AddReturnTypeDeclaration( + 'Symfony\Component\Templating\Helper\HelperInterface', + 'getName', + new StringType() + ), + ]); +}; diff --git a/config/sets/symfony/symfony6/symfony60/symfony60-translation.php b/config/sets/symfony/symfony6/symfony60/symfony60-translation.php new file mode 100644 index 000000000..eec9dcb1a --- /dev/null +++ b/config/sets/symfony/symfony6/symfony60/symfony60-translation.php @@ -0,0 +1,30 @@ +ruleWithConfiguration(AddReturnTypeDeclarationRector::class, [ + new AddReturnTypeDeclaration( + 'Symfony\Component\Translation\Extractor\AbstractFileExtractor', + 'canBeExtracted', + new BooleanType() + ), + new AddReturnTypeDeclaration( + 'Symfony\Component\Translation\Extractor\AbstractFileExtractor', + 'extractFromDirectory', + $iterableType + ), + ]); +}; diff --git a/config/sets/symfony/symfony6/symfony60/symfony60-validator.php b/config/sets/symfony/symfony6/symfony60/symfony60-validator.php new file mode 100644 index 000000000..a1602ae4e --- /dev/null +++ b/config/sets/symfony/symfony6/symfony60/symfony60-validator.php @@ -0,0 +1,35 @@ +ruleWithConfiguration(AddReturnTypeDeclarationRector::class, [ + new AddReturnTypeDeclaration( + 'Symfony\Component\Validator\Constraint', + 'getDefaultOption', + $nullableStringType + ), + new AddReturnTypeDeclaration('Symfony\Component\Validator\Constraint', 'getRequiredOptions', $arrayType), + new AddReturnTypeDeclaration('Symfony\Component\Validator\Constraint', 'validatedBy', new StringType()), + new AddReturnTypeDeclaration( + 'Symfony\Component\Validator\Constraint', + 'getTargets', + new UnionType([new StringType(), $arrayType]) + ), + ]); +}; diff --git a/src/Set/SetProvider/Symfony6SetProvider.php b/src/Set/SetProvider/Symfony6SetProvider.php index 86d729845..bc8d08c74 100644 --- a/src/Set/SetProvider/Symfony6SetProvider.php +++ b/src/Set/SetProvider/Symfony6SetProvider.php @@ -66,6 +66,97 @@ public function provide(): array __DIR__ . '/../../../config/sets/symfony/symfony6/symfony60/symfony60-security-core.php' ), + new ComposerTriggeredSet( + SetGroup::SYMFONY, + 'symfony/serializer', + '6.0', + __DIR__ . '/../../../config/sets/symfony/symfony6/symfony60/symfony60-serializer.php' + ), + new ComposerTriggeredSet( + SetGroup::SYMFONY, + 'symfony/security-http', + '6.0', + __DIR__ . '/../../../config/sets/symfony/symfony6/symfony60/symfony60-security-http.php' + ), + new ComposerTriggeredSet( + SetGroup::SYMFONY, + 'symfony/console', + '6.0', + __DIR__ . '/../../../config/sets/symfony/symfony6/symfony60/symfony60-console.php' + ), + new ComposerTriggeredSet( + SetGroup::SYMFONY, + 'symfony/browser-kit', + '6.0', + __DIR__ . '/../../../config/sets/symfony/symfony6/symfony60/symfony60-browser-kit.php' + ), + new ComposerTriggeredSet( + SetGroup::SYMFONY, + 'symfony/http-kernel', + '6.0', + __DIR__ . '/../../../config/sets/symfony/symfony6/symfony60/symfony60-http-kernel.php' + ), + new ComposerTriggeredSet( + SetGroup::SYMFONY, + 'symfony/validator', + '6.0', + __DIR__ . '/../../../config/sets/symfony/symfony6/symfony60/symfony60-validator.php' + ), + new ComposerTriggeredSet( + SetGroup::SYMFONY, + 'symfony/form', + '6.0', + __DIR__ . '/../../../config/sets/symfony/symfony6/symfony60/symfony60-form.php' + ), + new ComposerTriggeredSet( + SetGroup::SYMFONY, + 'symfony/translation', + '6.0', + __DIR__ . '/../../../config/sets/symfony/symfony6/symfony60/symfony60-translation.php' + ), + new ComposerTriggeredSet( + SetGroup::SYMFONY, + 'symfony/property-access', + '6.0', + __DIR__ . '/../../../config/sets/symfony/symfony6/symfony60/symfony60-property-access.php' + ), + new ComposerTriggeredSet( + SetGroup::SYMFONY, + 'symfony/property-info', + '6.0', + __DIR__ . '/../../../config/sets/symfony/symfony6/symfony60/symfony60-property-info.php' + ), + new ComposerTriggeredSet( + SetGroup::SYMFONY, + 'symfony/routing', + '6.0', + __DIR__ . '/../../../config/sets/symfony/symfony6/symfony60/symfony60-routing.php' + ), + new ComposerTriggeredSet( + SetGroup::SYMFONY, + 'symfony/templating', + '6.0', + __DIR__ . '/../../../config/sets/symfony/symfony6/symfony60/symfony60-templating.php' + ), + new ComposerTriggeredSet( + SetGroup::SYMFONY, + 'symfony/event-dispatcher', + '6.0', + __DIR__ . '/../../../config/sets/symfony/symfony6/symfony60/symfony60-event-dispatcher.php' + ), + new ComposerTriggeredSet( + SetGroup::SYMFONY, + 'symfony/expression-language', + '6.0', + __DIR__ . '/../../../config/sets/symfony/symfony6/symfony60/symfony60-expression-language.php' + ), + new ComposerTriggeredSet( + SetGroup::SYMFONY, + 'symfony/options-resolver', + '6.0', + __DIR__ . '/../../../config/sets/symfony/symfony6/symfony60/symfony60-options-resolver.php' + ), + new ComposerTriggeredSet( SetGroup::SYMFONY, 'symfony/symfony',