rector/config/set/symfony42.php

193 lines
8.1 KiB
PHP
Raw Normal View History

2020-07-18 18:57:24 +02:00
<?php
declare(strict_types=1);
use Rector\Generic\Rector\ClassMethod\AddReturnTypeDeclarationRector;
use Rector\Generic\Rector\ClassMethod\ArgumentAdderRector;
use Rector\Generic\Rector\ClassMethod\ArgumentDefaultValueReplacerRector;
use Rector\Generic\Rector\ClassMethod\ArgumentRemoverRector;
use Rector\Generic\Rector\ClassMethod\ChangeMethodVisibilityRector;
use Rector\Generic\Rector\ClassMethod\WrapReturnRector;
use Rector\Generic\Rector\New_\NewToStaticCallRector;
2020-07-18 18:57:24 +02:00
use Rector\Renaming\Rector\MethodCall\RenameMethodRector;
use Rector\Renaming\Rector\Name\RenameClassRector;
use Rector\Renaming\ValueObject\MethodCallRename;
use Rector\Symfony\Rector\MethodCall\ContainerGetToConstructorInjectionRector;
2020-07-18 18:57:24 +02:00
use Rector\Symfony\Rector\New_\RootNodeTreeBuilderRector;
use Rector\Symfony\Rector\New_\StringToArrayArgumentProcessRector;
use function Rector\SymfonyPhpConfig\inline_value_objects;
2020-07-18 18:57:24 +02:00
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
2020-07-18 19:00:36 +02:00
# https://github.com/symfony/symfony/pull/28447
2020-07-18 18:57:24 +02:00
return static function (ContainerConfigurator $containerConfigurator): void {
$services = $containerConfigurator->services();
$services->set(NewToStaticCallRector::class)
->call('configure', [[
2020-07-30 01:39:41 +02:00
NewToStaticCallRector::TYPE_TO_STATIC_CALLS => [
'Symfony\Component\HttpFoundation\Cookie' => ['Symfony\Component\HttpFoundation\Cookie', 'create'],
],
]]);
2020-07-18 18:57:24 +02:00
$services->set(RenameClassRector::class)
->call('configure', [[
2020-07-30 01:39:41 +02:00
RenameClassRector::OLD_TO_NEW_CLASSES => [
# https://github.com/symfony/symfony/commit/a7e319d9e1316e2e18843f8ce15b67a8693e5bf9
'Symfony\Bundle\FrameworkBundle\Controller\Controller' => 'Symfony\Bundle\FrameworkBundle\Controller\AbstractController',
# https://github.com/symfony/symfony/commit/744bf0e7ac3ecf240d0bf055cc58f881bb0b3ec0
'Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand' => 'Symfony\Component\Console\Command\Command',
'Symfony\Component\Translation\TranslatorInterface' => 'Symfony\Contracts\Translation\TranslatorInterface',
],
]]);
2020-07-18 18:57:24 +02:00
# related to "Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand" deprecation, see https://github.com/rectorphp/rector/issues/1629
$services->set(ContainerGetToConstructorInjectionRector::class);
# https://symfony.com/blog/new-in-symfony-4-2-important-deprecations
$services->set(StringToArrayArgumentProcessRector::class);
$services->set(RootNodeTreeBuilderRector::class);
$services->set(ArgumentAdderRector::class)
->call('configure', [[
2020-07-30 01:39:41 +02:00
ArgumentAdderRector::POSITION_WITH_DEFAULT_VALUE_BY_METHOD_NAMES_BY_CLASS_TYPES => [
'Symfony\Component\BrowserKit\Client' => [
'submit' => [
2 => [
# https://github.com/symfony/symfony/commit/fa2063efe43109aea093d6fbfc12d675dba82146
# https://github.com/symfony/symfony/commit/e3aa90f852f69040be19da3d8729cdf02d238ec7
'name' => 'serverParameters',
'default_value' => [],
'scope' => ['method_call'],
],
2020-07-18 18:57:24 +02:00
],
],
'Symfony\Component\DomCrawler\Crawler' => [
'children' => [[
# https://github.com/symfony/symfony/commit/f634afdb6f573e4af8d89aaa605e0c7d4058676d
# $selector
2020-07-18 18:57:24 +02:00
'default_value' => null,
'scope' => ['method_call'],
]],
],
'Symfony\Component\Finder\Finder' => [
'sortByName' => [[
# $useNaturalSort
'default_value' => false,
'scope' => ['method_call'],
]],
],
'Symfony\Bridge\Monolog\Processor\DebugProcessor' => [
'getLogs' => [[
# $request
'default_value' => null,
'scope' => ['method_call'],
]],
'countErrors' => [[
# $request
'default_value' => null,
2020-07-18 18:57:24 +02:00
'scope' => ['method_call'],
]],
],
'Symfony\Bridge\Monolog\Logger' => [
'getLogs' => [[
# $request
'default_value' => null,
'scope' => ['method_call'],
]],
'countErrors' => [[
# $request
'default_value' => null,
'scope' => ['method_call'],
]],
],
'Symfony\Component\Serializer\Normalizer' => [
'handleCircularReference' => [
1 => [
# $format
'default_value' => null,
'scope' => ['method_call'],
],
2 => [
# $context
'default_value' => [],
'scope' => ['method_call'],
],
2020-07-18 18:57:24 +02:00
],
],
],
]]);
2020-07-18 18:57:24 +02:00
$services->set(RenameMethodRector::class)
->call('configure', [[
RenameMethodRector::METHOD_CALL_RENAMES => inline_value_objects([
new MethodCallRename('Symfony\Component\Cache\CacheItem', 'getPreviousTags', 'getMetadata'),
new MethodCallRename(
'Symfony\Component\Form\AbstractTypeExtension',
'getExtendedType',
'getExtendedTypes'
),
]),
]]);
2020-07-18 18:57:24 +02:00
$services->set(AddReturnTypeDeclarationRector::class)
->call('configure', [[
2020-07-30 01:39:41 +02:00
AddReturnTypeDeclarationRector::TYPEHINT_FOR_METHOD_BY_CLASS => [
'Symfony\Component\Form\AbstractTypeExtension' => [
'getExtendedTypes' => 'iterable',
],
2020-07-18 18:57:24 +02:00
],
]]);
2020-07-18 18:57:24 +02:00
$services->set(ChangeMethodVisibilityRector::class)
->call('configure', [[
2020-07-30 01:39:41 +02:00
ChangeMethodVisibilityRector::METHOD_TO_VISIBILITY_BY_CLASS => [
'Symfony\Component\Form\AbstractTypeExtension' => [
'getExtendedTypes' => 'static',
],
2020-07-18 18:57:24 +02:00
],
]]);
2020-07-18 18:57:24 +02:00
$services->set(WrapReturnRector::class)
->call('configure', [[
2020-07-30 01:39:41 +02:00
WrapReturnRector::TYPE_TO_METHOD_TO_WRAP => [
'Symfony\Component\Form\AbstractTypeExtension' => [
'getExtendedTypes' => 'array',
],
2020-07-18 18:57:24 +02:00
],
]]);
2020-07-18 18:57:24 +02:00
$services->set(ArgumentDefaultValueReplacerRector::class)
->call('configure', [[
2020-07-30 01:39:41 +02:00
ArgumentDefaultValueReplacerRector::REPLACES_BY_METHOD_AND_TYPES => [
'Symfony\Component\HttpFoundation\Cookie' => [
'__construct' => [
5 => [
# https://github.com/symfony/symfony/commit/9493cfd5f2366dab19bbdde0d0291d0575454567
'before' => false,
'after' => null,
],
8 => [
'before' => null,
'after' => 'lax',
],
2020-07-18 18:57:24 +02:00
],
],
],
]]);
2020-07-18 18:57:24 +02:00
$services->set(ArgumentRemoverRector::class)
->call('configure', [[
2020-07-30 01:39:41 +02:00
ArgumentRemoverRector::POSITIONS_BY_METHOD_NAME_BY_CLASS_TYPE => [
'Symfony\Component\HttpKernel\DataCollector\ConfigDataCollector' => [
'__construct' => [
# https://github.com/symfony/symfony/commit/f5c355e1ba399a1b3512367647d902148bdaf09f
null,
null,
],
2020-07-18 18:57:24 +02:00
],
],
]]);
2020-07-18 18:57:24 +02:00
};