2020-07-18 18:57:24 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
declare(strict_types=1);
|
|
|
|
|
2020-08-18 17:57:30 +02:00
|
|
|
use Rector\Renaming\Rector\ClassConstFetch\RenameClassConstantRector;
|
2020-07-18 18:57:24 +02:00
|
|
|
use Rector\Renaming\Rector\MethodCall\RenameMethodRector;
|
2020-08-26 12:54:53 +02:00
|
|
|
|
2020-08-18 17:57:30 +02:00
|
|
|
use Rector\Renaming\Rector\Name\RenameClassRector;
|
2020-08-25 00:26:14 +02:00
|
|
|
use Rector\Renaming\ValueObject\MethodCallRename;
|
2020-09-12 23:19:08 +02:00
|
|
|
use Rector\Renaming\ValueObject\RenameClassConstant;
|
2020-08-12 11:08:59 +02:00
|
|
|
use Rector\Symfony\Rector\ClassMethod\FormTypeGetParentRector;
|
|
|
|
use Rector\Symfony\Rector\ClassMethod\GetRequestRector;
|
2020-07-18 18:57:24 +02:00
|
|
|
use Rector\Symfony\Rector\ClassMethod\RemoveDefaultGetBlockPrefixRector;
|
|
|
|
use Rector\Symfony\Rector\MethodCall\CascadeValidationFormBuilderRector;
|
|
|
|
use Rector\Symfony\Rector\MethodCall\ChangeCollectionTypeOptionNameFromTypeToEntryTypeRector;
|
|
|
|
use Rector\Symfony\Rector\MethodCall\ChangeCollectionTypeOptionTypeFromStringToClassReferenceRector;
|
|
|
|
use Rector\Symfony\Rector\MethodCall\FormTypeInstanceToClassConstRector;
|
2020-08-12 11:08:59 +02:00
|
|
|
use Rector\Symfony\Rector\MethodCall\OptionNameRector;
|
2020-07-18 18:57:24 +02:00
|
|
|
use Rector\Symfony\Rector\MethodCall\ReadOnlyOptionToAttributeRector;
|
2020-08-12 11:08:59 +02:00
|
|
|
use Rector\Symfony\Rector\MethodCall\StringFormTypeToClassRector;
|
2020-08-26 12:54:53 +02:00
|
|
|
use Rector\SymfonyPhpConfig\inline_value_objects;
|
2020-08-25 00:26:14 +02:00
|
|
|
use function Rector\SymfonyPhpConfig\inline_value_objects;
|
2020-07-18 18:57:24 +02:00
|
|
|
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
|
|
|
|
|
|
|
return static function (ContainerConfigurator $containerConfigurator): void {
|
|
|
|
$services = $containerConfigurator->services();
|
|
|
|
|
|
|
|
# resources:
|
|
|
|
# - https://github.com/symfony/symfony/blob/3.4/UPGRADE-3.0.md
|
|
|
|
# php
|
|
|
|
$services->set(GetRequestRector::class);
|
|
|
|
$services->set(FormTypeGetParentRector::class);
|
|
|
|
$services->set(OptionNameRector::class);
|
|
|
|
$services->set(ReadOnlyOptionToAttributeRector::class);
|
|
|
|
|
|
|
|
# forms
|
|
|
|
$services->set(FormTypeInstanceToClassConstRector::class);
|
|
|
|
$services->set(StringFormTypeToClassRector::class);
|
|
|
|
$services->set(CascadeValidationFormBuilderRector::class);
|
|
|
|
$services->set(RemoveDefaultGetBlockPrefixRector::class);
|
|
|
|
|
|
|
|
# forms - collection
|
|
|
|
$services->set(ChangeCollectionTypeOptionTypeFromStringToClassReferenceRector::class);
|
|
|
|
$services->set(ChangeCollectionTypeOptionNameFromTypeToEntryTypeRector::class);
|
|
|
|
|
|
|
|
$services->set(RenameClassConstantRector::class)
|
2020-07-30 00:43:06 +02:00
|
|
|
->call('configure', [[
|
2020-08-26 12:54:53 +02:00
|
|
|
RenameClassConstantRector::CLASS_CONSTANT_RENAME => inline_value_objects([
|
2020-09-12 23:19:08 +02:00
|
|
|
new RenameClassConstant('Symfony\Component\Form\FormEvents', 'PRE_BIND', 'PRE_SUBMIT'),
|
|
|
|
new RenameClassConstant('Symfony\Component\Form\FormEvents', 'BIND', 'SUBMIT'),
|
|
|
|
new RenameClassConstant('Symfony\Component\Form\FormEvents', 'POST_BIND', 'POST_SUBMIT'),
|
|
|
|
new RenameClassConstant(
|
2020-08-26 12:54:53 +02:00
|
|
|
'Symfony\Component\Form\Extension\Core\DataTransformer',
|
|
|
|
'ROUND_HALFEVEN',
|
|
|
|
'ROUND_HALF_EVEN'
|
|
|
|
),
|
2020-09-12 23:19:08 +02:00
|
|
|
new RenameClassConstant(
|
2020-08-26 12:54:53 +02:00
|
|
|
'Symfony\Component\Form\Extension\Core\DataTransformer',
|
|
|
|
'ROUND_HALFUP',
|
|
|
|
'ROUND_HALF_UP'
|
|
|
|
),
|
2020-09-12 23:19:08 +02:00
|
|
|
new RenameClassConstant(
|
2020-08-26 12:54:53 +02:00
|
|
|
'Symfony\Component\Form\Extension\Core\DataTransformer',
|
|
|
|
'ROUND_HALFDOWN',
|
|
|
|
'ROUND_HALF_DOWN'
|
|
|
|
),
|
|
|
|
]),
|
2020-07-30 00:43:06 +02:00
|
|
|
]]);
|
2020-07-18 18:57:24 +02:00
|
|
|
|
|
|
|
$services->set(RenameMethodRector::class)
|
2020-07-30 00:43:06 +02:00
|
|
|
->call('configure', [[
|
2020-08-25 00:37:12 +02:00
|
|
|
RenameMethodRector::METHOD_CALL_RENAMES => inline_value_objects([
|
2020-08-25 00:26:14 +02:00
|
|
|
// class loader
|
|
|
|
new MethodCallRename(
|
|
|
|
'Symfony\Component\ClassLoader\UniversalClassLoader\UniversalClassLoader',
|
|
|
|
'registerNamespaces',
|
|
|
|
'addPrefixes'
|
|
|
|
),
|
|
|
|
new MethodCallRename(
|
|
|
|
'Symfony\Component\ClassLoader\UniversalClassLoader\UniversalClassLoader',
|
|
|
|
'registerPrefixes',
|
|
|
|
'addPrefixes'
|
|
|
|
),
|
|
|
|
new MethodCallRename(
|
|
|
|
'Symfony\Component\ClassLoader\UniversalClassLoader\UniversalClassLoader',
|
|
|
|
'registerNamespace',
|
|
|
|
'addPrefix'
|
|
|
|
),
|
|
|
|
new MethodCallRename(
|
|
|
|
'Symfony\Component\ClassLoader\UniversalClassLoader\UniversalClassLoader',
|
|
|
|
'registerPrefix',
|
|
|
|
'addPrefix'
|
|
|
|
),
|
|
|
|
new MethodCallRename(
|
|
|
|
'Symfony\Component\ClassLoader\UniversalClassLoader\UniversalClassLoader',
|
|
|
|
'getNamespaces',
|
|
|
|
'getPrefixes'
|
|
|
|
),
|
|
|
|
new MethodCallRename(
|
|
|
|
'Symfony\Component\ClassLoader\UniversalClassLoader\UniversalClassLoader',
|
|
|
|
'getNamespaceFallbacks',
|
|
|
|
'getFallbackDirs'
|
|
|
|
),
|
|
|
|
new MethodCallRename(
|
|
|
|
'Symfony\Component\ClassLoader\UniversalClassLoader\UniversalClassLoader',
|
|
|
|
'getPrefixFallbacks',
|
|
|
|
'getFallbackDirs'
|
|
|
|
),
|
|
|
|
// form
|
|
|
|
new MethodCallRename('Symfony\Component\Form\AbstractType', 'getName', 'getBlockPrefix'),
|
|
|
|
new MethodCallRename('Symfony\Component\Form\AbstractType', 'setDefaultOptions', 'configureOptions'),
|
|
|
|
new MethodCallRename('Symfony\Component\Form\FormTypeInterface', 'getName', 'getBlockPrefix'),
|
|
|
|
new MethodCallRename(
|
|
|
|
'Symfony\Component\Form\FormTypeInterface',
|
|
|
|
'setDefaultOptions',
|
|
|
|
'configureOptions'
|
|
|
|
),
|
|
|
|
new MethodCallRename('Symfony\Component\Form\ResolvedFormTypeInterface', 'getName', 'getBlockPrefix'),
|
|
|
|
new MethodCallRename(
|
|
|
|
'Symfony\Component\Form\AbstractTypeExtension',
|
|
|
|
'setDefaultOptions',
|
|
|
|
'configureOptions'
|
|
|
|
),
|
|
|
|
new MethodCallRename('Symfony\Component\Form\Form', 'bind', 'submit'),
|
|
|
|
new MethodCallRename('Symfony\Component\Form\Form', 'isBound', 'isSubmitted'),
|
|
|
|
// process
|
|
|
|
new MethodCallRename('Symfony\Component\Process\Process', 'setStdin', 'setInput'),
|
|
|
|
new MethodCallRename('Symfony\Component\Process\Process', 'getStdin', 'getInput'),
|
|
|
|
// monolog
|
|
|
|
new MethodCallRename('Symfony\Bridge\Monolog\Logger', 'emerg', 'emergency'),
|
|
|
|
new MethodCallRename('Symfony\Bridge\Monolog\Logger', 'crit', 'critical'),
|
|
|
|
new MethodCallRename('Symfony\Bridge\Monolog\Logger', 'err', 'error'),
|
|
|
|
new MethodCallRename('Symfony\Bridge\Monolog\Logger', 'warn', 'warning'),
|
|
|
|
# http kernel
|
|
|
|
new MethodCallRename('Symfony\Component\HttpKernel\Log\LoggerInterface', 'emerg', 'emergency'),
|
|
|
|
new MethodCallRename('Symfony\Component\HttpKernel\Log\LoggerInterface', 'crit', 'critical'),
|
|
|
|
new MethodCallRename('Symfony\Component\HttpKernel\Log\LoggerInterface', 'err', 'error'),
|
|
|
|
new MethodCallRename('Symfony\Component\HttpKernel\Log\LoggerInterface', 'warn', 'warning'),
|
|
|
|
new MethodCallRename('Symfony\Component\HttpKernel\Log\NullLogger', 'emerg', 'emergency'),
|
|
|
|
new MethodCallRename('Symfony\Component\HttpKernel\Log\NullLogger', 'crit', 'critical'),
|
|
|
|
new MethodCallRename('Symfony\Component\HttpKernel\Log\NullLogger', 'err', 'error'),
|
|
|
|
new MethodCallRename('Symfony\Component\HttpKernel\Log\NullLogger', 'warn', 'warning'),
|
|
|
|
// property access
|
|
|
|
new MethodCallRename(
|
|
|
|
'getPropertyAccessor',
|
|
|
|
'Symfony\Component\PropertyAccess\PropertyAccess',
|
|
|
|
'createPropertyAccessor'
|
|
|
|
),
|
|
|
|
// translator
|
|
|
|
new MethodCallRename(
|
|
|
|
'Symfony\Component\Translation\Dumper\FileDumper',
|
|
|
|
'format',
|
|
|
|
'formatCatalogue'
|
|
|
|
),
|
|
|
|
new MethodCallRename('Symfony\Component\Translation\Translator', 'getMessages', 'getCatalogue'),
|
|
|
|
// validator
|
|
|
|
new MethodCallRename(
|
|
|
|
'Symfony\Component\Validator\ConstraintViolationInterface',
|
|
|
|
'getMessageParameters',
|
|
|
|
'getParameters'
|
|
|
|
),
|
|
|
|
new MethodCallRename(
|
|
|
|
'Symfony\Component\Validator\ConstraintViolationInterface',
|
|
|
|
'getMessagePluralization',
|
|
|
|
'getPlural'
|
|
|
|
),
|
|
|
|
new MethodCallRename(
|
|
|
|
'Symfony\Component\Validator\ConstraintViolation',
|
|
|
|
'getMessageParameters',
|
|
|
|
'getParameters'
|
|
|
|
),
|
|
|
|
new MethodCallRename(
|
|
|
|
'Symfony\Component\Validator\ConstraintViolation',
|
|
|
|
'getMessagePluralization',
|
|
|
|
'getPlural'
|
|
|
|
),
|
|
|
|
]),
|
2020-07-30 00:43:06 +02:00
|
|
|
]]);
|
|
|
|
|
|
|
|
$services->set(RenameClassRector::class)
|
|
|
|
->call('configure', [[
|
2020-07-30 01:39:41 +02:00
|
|
|
RenameClassRector::OLD_TO_NEW_CLASSES => [
|
2020-07-18 18:57:24 +02:00
|
|
|
# class loader
|
2020-07-30 00:43:06 +02:00
|
|
|
# partial with method rename
|
|
|
|
'Symfony\Component\ClassLoader\UniversalClassLoader\UniversalClassLoader' => 'Symfony\Component\ClassLoader\ClassLoader',
|
|
|
|
# console
|
|
|
|
'Symfony\Component\Console\Helper\ProgressHelper' => 'Symfony\Component\Console\Helper\ProgressBar',
|
2020-07-18 18:57:24 +02:00
|
|
|
# form
|
2020-07-30 00:43:06 +02:00
|
|
|
'Symfony\Component\Form\Util\VirtualFormAwareIterator' => 'Symfony\Component\Form\Util\InheritDataAwareIterator',
|
|
|
|
'Symfony\Component\Form\Tests\Extension\Core\Type\TypeTestCase' => 'Symfony\Component\Form\Test\TypeTestCase',
|
|
|
|
'Symfony\Component\Form\Tests\FormIntegrationTestCase' => 'Symfony\Component\Form\Test\FormIntegrationTestCase',
|
|
|
|
'Symfony\Component\Form\Tests\FormPerformanceTestCase' => 'Symfony\Component\Form\Test\FormPerformanceTestCase',
|
|
|
|
'Symfony\Component\Form\Extension\Core\ChoiceList\ChoiceListInterface' => 'Symfony\Component\Form\ChoiceList\ChoiceListInterface',
|
|
|
|
'Symfony\Component\Form\Extension\Core\View\ChoiceView' => 'Symfony\Component\Form\ChoiceList\View\ChoiceView',
|
|
|
|
'Symfony\Component\Form\Extension\Csrf\CsrfProvider\CsrfProviderInterface' => 'Symfony\Component\Security\Csrf\CsrfTokenManagerInterface',
|
|
|
|
'Symfony\Component\Form\Extension\Core\ChoiceList\ChoiceList' => 'Symfony\Component\Form\ChoiceList\ArrayChoiceList',
|
|
|
|
'Symfony\Component\Form\Extension\Core\ChoiceList\LazyChoiceList' => 'Symfony\Component\Form\ChoiceList\LazyChoiceList',
|
|
|
|
'Symfony\Component\Form\Extension\Core\ChoiceList\ObjectChoiceList' => 'Symfony\Component\Form\ChoiceList\ArrayChoiceList',
|
|
|
|
'Symfony\Component\Form\Extension\Core\ChoiceList\SimpleChoiceList' => 'Symfony\Component\Form\ChoiceList\ArrayChoiceList',
|
|
|
|
'Symfony\Component\Form\ChoiceList\ArrayKeyChoiceList' => 'Symfony\Component\Form\ChoiceList\ArrayChoiceList',
|
2020-07-18 18:57:24 +02:00
|
|
|
# http kernel
|
2020-07-30 00:43:06 +02:00
|
|
|
'Symfony\Component\HttpKernel\Debug\ErrorHandler' => 'Symfony\Component\Debug\ErrorHandler',
|
|
|
|
'Symfony\Component\HttpKernel\Debug\ExceptionHandler' => 'Symfony\Component\Debug\ExceptionHandler',
|
|
|
|
'Symfony\Component\HttpKernel\Exception\FatalErrorException' => 'Symfony\Component\Debug\Exception\FatalErrorException',
|
|
|
|
'Symfony\Component\HttpKernel\Exception\FlattenException' => 'Symfony\Component\Debug\Exception\FlattenException',
|
|
|
|
# partial with method rename
|
|
|
|
'Symfony\Component\HttpKernel\Log\LoggerInterface' => 'Psr\Log\LoggerInterface',
|
|
|
|
# event disptacher
|
|
|
|
'Symfony\Component\HttpKernel\DependencyInjection\RegisterListenersPass' => 'Symfony\Component\EventDispatcher\DependencyInjection\RegisterListenersPass',
|
|
|
|
# partial with methor rename
|
|
|
|
'Symfony\Component\HttpKernel\Log\NullLogger' => 'Psr\Log\LoggerInterface',
|
|
|
|
# monolog
|
|
|
|
# partial with method rename
|
|
|
|
'Symfony\Bridge\Monolog\Logger' => 'Psr\Log\LoggerInterface',
|
|
|
|
# security
|
|
|
|
'Symfony\Component\Security\Core\Authorization\Voter\AbstractVoter' => 'Symfony\Component\Security\Core\Authorization\Voter\Voter',
|
2020-07-18 18:57:24 +02:00
|
|
|
# translator
|
2020-07-30 00:43:06 +02:00
|
|
|
# partial with class rename
|
|
|
|
'Symfony\Component\Translation\Translator' => 'Symfony\Component\Translation\TranslatorBagInterface',
|
|
|
|
# twig
|
|
|
|
'Symfony\Bundle\TwigBundle\TwigDefaultEscapingStrategy' => 'Twig_FileExtensionEscapingStrategy',
|
2020-07-18 18:57:24 +02:00
|
|
|
# validator
|
2020-07-30 00:43:06 +02:00
|
|
|
'Symfony\Component\Validator\Constraints\Collection\Optional' => 'Symfony\Component\Validator\Constraints\Optional',
|
|
|
|
'Symfony\Component\Validator\Constraints\Collection\Required' => 'Symfony\Component\Validator\Constraints\Required',
|
|
|
|
'Symfony\Component\Validator\MetadataInterface' => 'Symfony\Component\Validator\Mapping\MetadataInterface',
|
|
|
|
'Symfony\Component\Validator\PropertyMetadataInterface' => 'Symfony\Component\Validator\Mapping\PropertyMetadataInterface',
|
|
|
|
'Symfony\Component\Validator\PropertyMetadataContainerInterface' => 'Symfony\Component\Validator\Mapping\ClassMetadataInterface',
|
|
|
|
'Symfony\Component\Validator\ClassBasedInterface' => 'Symfony\Component\Validator\Mapping\ClassMetadataInterface',
|
|
|
|
'Symfony\Component\Validator\Mapping\ElementMetadata' => 'Symfony\Component\Validator\Mapping\GenericMetadata',
|
|
|
|
'Symfony\Component\Validator\ExecutionContextInterface' => 'Symfony\Component\Validator\Context\ExecutionContextInterface',
|
|
|
|
'Symfony\Component\Validator\Mapping\ClassMetadataFactory' => 'Symfony\Component\Validator\Mapping\Factory\LazyLoadingMetadataFactory',
|
|
|
|
'Symfony\Component\Validator\Mapping\MetadataFactoryInterface' => 'Symfony\Component\Validator\Mapping\Factory\MetadataFactoryInterface',
|
|
|
|
# swift mailer
|
|
|
|
'Symfony\Bridge\Swiftmailer\DataCollector\MessageDataCollector' => 'Symfony\Bundle\SwiftmailerBundle\DataCollector\MessageDataCollector',
|
|
|
|
],
|
|
|
|
]]);
|
2020-07-18 18:57:24 +02:00
|
|
|
};
|