Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
584 changes: 0 additions & 584 deletions config/sets/symfony/symfony6/symfony-return-types.php

This file was deleted.

17 changes: 15 additions & 2 deletions config/sets/symfony/symfony6/symfony60.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
38 changes: 38 additions & 0 deletions config/sets/symfony/symfony6/symfony60/symfony60-browser-kit.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?php

declare(strict_types=1);

use PHPStan\Type\ObjectType;
use PHPStan\Type\ObjectWithoutClassType;
use Rector\Config\RectorConfig;
use Rector\TypeDeclaration\Rector\ClassMethod\AddReturnTypeDeclarationRector;
use Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration;

// https://github.com/symfony/symfony/blob/6.1/UPGRADE-6.0.md
// @see https://github.com/symfony/symfony/blob/6.1/.github/expected-missing-return-types.diff

return static function (RectorConfig $rectorConfig): void {
$browserKitResponseType = new ObjectType('Symfony\Component\BrowserKit\Response');
$rectorConfig->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
),
]);
};
50 changes: 50 additions & 0 deletions config/sets/symfony/symfony6/symfony60/symfony60-config.php
Original file line number Diff line number Diff line change
Expand Up @@ -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, [
Expand All @@ -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()
),
]);
};
65 changes: 65 additions & 0 deletions config/sets/symfony/symfony6/symfony60/symfony60-console.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
<?php

declare(strict_types=1);

use PHPStan\Type\ArrayType;
use PHPStan\Type\BooleanType;
use PHPStan\Type\IntegerType;
use PHPStan\Type\MixedType;
use PHPStan\Type\NullType;
use PHPStan\Type\ObjectType;
use PHPStan\Type\StringType;
use PHPStan\Type\UnionType;
use Rector\Config\RectorConfig;
use Rector\TypeDeclaration\Rector\ClassMethod\AddReturnTypeDeclarationRector;
use Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration;

// https://github.com/symfony/symfony/blob/6.1/UPGRADE-6.0.md
// @see https://github.com/symfony/symfony/blob/6.1/.github/expected-missing-return-types.diff

return static function (RectorConfig $rectorConfig): void {
$arrayType = new ArrayType(new MixedType(), new MixedType());
$commandType = new ObjectType('Symfony\Component\Console\Command\Command');

$rectorConfig->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()
),
]);
};
Original file line number Diff line number Diff line change
Expand Up @@ -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, [
Expand All @@ -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)
),
]);
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php

declare(strict_types=1);

use PHPStan\Type\ArrayType;
use PHPStan\Type\MixedType;
use Rector\Config\RectorConfig;
use Rector\TypeDeclaration\Rector\ClassMethod\AddReturnTypeDeclarationRector;
use Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration;

// https://github.com/symfony/symfony/blob/6.1/UPGRADE-6.0.md
// @see https://github.com/symfony/symfony/blob/6.1/.github/expected-missing-return-types.diff

return static function (RectorConfig $rectorConfig): void {
$arrayType = new ArrayType(new MixedType(), new MixedType());

$rectorConfig->ruleWithConfiguration(AddReturnTypeDeclarationRector::class, [
new AddReturnTypeDeclaration(
'Symfony\Component\EventDispatcher\EventSubscriberInterface',
'getSubscribedEvents',
$arrayType
),
]);
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php

declare(strict_types=1);

use PHPStan\Type\ArrayType;
use PHPStan\Type\MixedType;
use Rector\Config\RectorConfig;
use Rector\TypeDeclaration\Rector\ClassMethod\AddReturnTypeDeclarationRector;
use Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration;

// https://github.com/symfony/symfony/blob/6.1/UPGRADE-6.0.md
// @see https://github.com/symfony/symfony/blob/6.1/.github/expected-missing-return-types.diff

return static function (RectorConfig $rectorConfig): void {
$arrayType = new ArrayType(new MixedType(), new MixedType());

$rectorConfig->ruleWithConfiguration(AddReturnTypeDeclarationRector::class, [
new AddReturnTypeDeclaration(
'Symfony\Component\ExpressionLanguage\ExpressionFunctionProviderInterface',
'getFunctions',
$arrayType
),
]);
};
Loading
Loading