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
172 changes: 12 additions & 160 deletions config/sets/symfony/symfony5/symfony52.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,171 +2,23 @@

declare(strict_types=1);

use PHPStan\Type\ObjectType;
use Rector\Config\RectorConfig;
use Rector\Renaming\Rector\ClassConstFetch\RenameClassConstFetchRector;
use Rector\Renaming\Rector\MethodCall\RenameMethodRector;
use Rector\Renaming\Rector\PropertyFetch\RenamePropertyRector;
use Rector\Renaming\ValueObject\MethodCallRename;
use Rector\Renaming\ValueObject\RenameClassAndConstFetch;
use Rector\Renaming\ValueObject\RenameProperty;
use Rector\Symfony\Set\SymfonySetList;
use Rector\Symfony\Symfony52\Rector\MethodCall\DefinitionAliasSetPrivateToSetPublicRector;
use Rector\Symfony\Symfony52\Rector\MethodCall\FormBuilderSetDataMapperRector;
use Rector\Symfony\Symfony52\Rector\MethodCall\ReflectionExtractorEnableMagicCallExtractorRector;
use Rector\Symfony\Symfony52\Rector\MethodCall\ValidatorBuilderEnableAnnotationMappingRector;
use Rector\Symfony\Symfony52\Rector\New_\PropertyAccessorCreationBooleanToFlagsRector;
use Rector\Symfony\Symfony52\Rector\New_\PropertyPathMapperToDataMapperRector;
use Rector\Symfony\Symfony52\Rector\StaticCall\BinaryFileResponseCreateToNewInstanceRector;
use Rector\TypeDeclaration\Rector\ClassMethod\AddParamTypeDeclarationRector;
use Rector\TypeDeclaration\ValueObject\AddParamTypeDeclaration;

# https://github.com/symfony/symfony/blob/5.x/UPGRADE-5.2.md

return static function (RectorConfig $rectorConfig): void {
$rectorConfig->sets([SymfonySetList::ANNOTATIONS_TO_ATTRIBUTES]);
// $rectorConfig->sets([SymfonySetList::ANNOTATIONS_TO_ATTRIBUTES]);

$rectorConfig->import(__DIR__ . '/symfony52/symfony52-dependency-injection.php');
$rectorConfig->import(__DIR__ . '/symfony52/symfony52-forms.php');
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the name should be symfony52-form.php instead of symfony-forms.php

Suggested change
$rectorConfig->import(__DIR__ . '/symfony52/symfony52-forms.php');
$rectorConfig->import(__DIR__ . '/symfony52/symfony52-form.php');

if name needs to follow component name https://github.com/symfony/form/blob/59b6c45ec432ff72b56c4ec5c68e0a107597623c/composer.json#L2

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well done 👍

$rectorConfig->import(__DIR__ . '/symfony52/symfony52-http-foundation.php');
$rectorConfig->import(__DIR__ . '/symfony52/symfony52-mime.php');
$rectorConfig->import(__DIR__ . '/symfony52/symfony52-notifier.php');
$rectorConfig->import(__DIR__ . '/symfony52/symfony52-property-access.php');
$rectorConfig->import(__DIR__ . '/symfony52/symfony52-property-info.php');
$rectorConfig->import(__DIR__ . '/symfony52/symfony52-security-core.php');
$rectorConfig->import(__DIR__ . '/symfony52/symfony52-security-http.php');
$rectorConfig->import(__DIR__ . '/symfony52/symfony52-validator.php');

$rectorConfig->rules([
// https://github.com/symfony/symfony/blob/5.x/UPGRADE-5.2.md#form
PropertyPathMapperToDataMapperRector::class,

// https://github.com/symfony/symfony/blob/5.x/UPGRADE-5.2.md#httpfoundation
BinaryFileResponseCreateToNewInstanceRector::class,

// https://github.com/symfony/symfony/blob/5.x/UPGRADE-5.2.md#propertyaccess
PropertyAccessorCreationBooleanToFlagsRector::class,

// https://github.com/symfony/symfony/blob/5.x/UPGRADE-5.2.md#propertyinfo
ReflectionExtractorEnableMagicCallExtractorRector::class,

# https://github.com/symfony/symfony/blob/5.x/UPGRADE-5.2.md#dependencyinjection
DefinitionAliasSetPrivateToSetPublicRector::class,

# https://github.com/symfony/symfony/blob/5.x/UPGRADE-5.2.md#form
FormBuilderSetDataMapperRector::class,

# https://github.com/symfony/symfony/blob/5.x/UPGRADE-5.2.md#validator
ValidatorBuilderEnableAnnotationMappingRector::class,
]);

# https://github.com/symfony/symfony/blob/5.x/UPGRADE-5.2.md#security
$rectorConfig->ruleWithConfiguration(RenameClassConstFetchRector::class, [
new RenameClassAndConstFetch(
'Symfony\Component\Security\Http\Firewall\AccessListener',
'PUBLIC_ACCESS',
'Symfony\Component\Security\Core\Authorization\Voter\AuthenticatedVoter',
'PUBLIC_ACCESS'
),
]);

$rectorConfig->ruleWithConfiguration(RenameMethodRector::class, [
# https://github.com/symfony/symfony/blob/5.x/UPGRADE-5.2.md#mime
new MethodCallRename('Symfony\Component\Mime\Address', 'fromString', 'create'),

new MethodCallRename(
'Symfony\Component\Security\Core\Authentication\Token\PreAuthenticatedToken',
'setProviderKey',
'setFirewallName'
),
new MethodCallRename(
'Symfony\Component\Security\Core\Authentication\Token\PreAuthenticatedToken',
'getProviderKey',
'getFirewallName'
),
new MethodCallRename(
'Symfony\Component\Security\Core\Authentication\Token\RememberMeToken',
'setProviderKey',
'setFirewallName'
),
new MethodCallRename(
'Symfony\Component\Security\Core\Authentication\Token\RememberMeToken',
'getProviderKey',
'getFirewallName'
),
new MethodCallRename(
'Symfony\Component\Security\Core\Authentication\Token\SwitchUserToken',
'setProviderKey',
'setFirewallName'
),
new MethodCallRename(
'Symfony\Component\Security\Core\Authentication\Token\SwitchUserToken',
'getProviderKey',
'getFirewallName'
),
new MethodCallRename(
'Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken',
'setProviderKey',
'setFirewallName'
),
new MethodCallRename(
'Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken',
'getProviderKey',
'getFirewallName'
),
new MethodCallRename(
'Symfony\Component\Security\Http\Authentication\DefaultAuthenticationSuccessHandler',
'setProviderKey',
'setFirewallName'
),
new MethodCallRename(
'Symfony\Component\Security\Http\Authentication\DefaultAuthenticationSuccessHandler',
'getProviderKey',
'getFirewallName'
),
]);

# https://github.com/symfony/symfony/blob/5.x/UPGRADE-5.2.md#notifier
$rectorConfig->ruleWithConfiguration(AddParamTypeDeclarationRector::class, [
new AddParamTypeDeclaration(
'Symfony\Component\Notifier\NotifierInterface',
'send',
1,
new ObjectType('Symfony\Component\Notifier\Recipient\RecipientInterface')
),
new AddParamTypeDeclaration(
'Symfony\Component\Notifier\Notifier',
'getChannels',
1,
new ObjectType('Symfony\Component\Notifier\Recipient\RecipientInterface')
),
new AddParamTypeDeclaration(
'Symfony\Component\Notifier\Channel\ChannelInterface',
'notify',
1,
new ObjectType('Symfony\Component\Notifier\Recipient\RecipientInterface')
),
new AddParamTypeDeclaration(
'Symfony\Component\Notifier\Channel\ChannelInterface',
'supports',
1,
new ObjectType('Symfony\Component\Notifier\Recipient\RecipientInterface')
),
new AddParamTypeDeclaration(
'Symfony\Component\Notifier\Notification\ChatNotificationInterface',
'asChatMessage',
0,
new ObjectType('Symfony\Component\Notifier\Recipient\RecipientInterface')
),
new AddParamTypeDeclaration(
'Symfony\Component\Notifier\Notification\EmailNotificationInterface',
'asEmailMessage',
0,
new ObjectType('Symfony\Component\Notifier\Recipient\EmailRecipientInterface')
),
new AddParamTypeDeclaration(
'Symfony\Component\Notifier\Notification\SmsNotificationInterface',
'asSmsMessage',
0,
new ObjectType('Symfony\Component\Notifier\Recipient\SmsRecipientInterface')
),
]);

# https://github.com/symfony/symfony/blob/5.x/UPGRADE-5.2.md#security
$rectorConfig->ruleWithConfiguration(RenamePropertyRector::class, [
new RenameProperty(
'Symfony\Component\Security\Http\RememberMe\AbstractRememberMeServices',
'providerKey',
'firewallName'
),
]);
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

declare(strict_types=1);

use Rector\Config\RectorConfig;
use Rector\Symfony\Symfony52\Rector\MethodCall\DefinitionAliasSetPrivateToSetPublicRector;

return static function (RectorConfig $rectorConfig): void {
$rectorConfig->rules([
# https://github.com/symfony/symfony/blob/5.x/UPGRADE-5.2.md#dependencyinjection
DefinitionAliasSetPrivateToSetPublicRector::class,
]);
};
12 changes: 12 additions & 0 deletions config/sets/symfony/symfony5/symfony52/symfony52-forms.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?php

declare(strict_types=1);

use Rector\Config\RectorConfig;
use Rector\Symfony\Symfony52\Rector\MethodCall\FormBuilderSetDataMapperRector;
use Rector\Symfony\Symfony52\Rector\New_\PropertyPathMapperToDataMapperRector;

// https://github.com/symfony/symfony/blob/5.x/UPGRADE-5.2.md#form
return static function (RectorConfig $rectorConfig): void {
$rectorConfig->rules([PropertyPathMapperToDataMapperRector::class, FormBuilderSetDataMapperRector::class]);
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

declare(strict_types=1);

use Rector\Config\RectorConfig;
use Rector\Symfony\Symfony52\Rector\StaticCall\BinaryFileResponseCreateToNewInstanceRector;

return static function (RectorConfig $rectorConfig): void {
$rectorConfig->rules([
// https://github.com/symfony/symfony/blob/5.x/UPGRADE-5.2.md#httpfoundation
BinaryFileResponseCreateToNewInstanceRector::class,
]);
};
16 changes: 16 additions & 0 deletions config/sets/symfony/symfony5/symfony52/symfony52-mime.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php

declare(strict_types=1);

use Rector\Config\RectorConfig;
use Rector\Renaming\Rector\MethodCall\RenameMethodRector;
use Rector\Renaming\ValueObject\MethodCallRename;

// https://github.com/symfony/symfony/blob/5.x/UPGRADE-5.2.md#form
return static function (RectorConfig $rectorConfig): void {

$rectorConfig->ruleWithConfiguration(RenameMethodRector::class, [
# https://github.com/symfony/symfony/blob/5.x/UPGRADE-5.2.md#mime
new MethodCallRename('Symfony\Component\Mime\Address', 'fromString', 'create'),
]);
};
56 changes: 56 additions & 0 deletions config/sets/symfony/symfony5/symfony52/symfony52-notifier.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<?php

declare(strict_types=1);

use PHPStan\Type\ObjectType;
use Rector\Config\RectorConfig;
use Rector\TypeDeclaration\Rector\ClassMethod\AddParamTypeDeclarationRector;
use Rector\TypeDeclaration\ValueObject\AddParamTypeDeclaration;

return static function (RectorConfig $rectorConfig): void {
# https://github.com/symfony/symfony/blob/5.x/UPGRADE-5.2.md#notifier
$rectorConfig->ruleWithConfiguration(AddParamTypeDeclarationRector::class, [
new AddParamTypeDeclaration(
'Symfony\Component\Notifier\NotifierInterface',
'send',
1,
new ObjectType('Symfony\Component\Notifier\Recipient\RecipientInterface')
),
new AddParamTypeDeclaration(
'Symfony\Component\Notifier\Notifier',
'getChannels',
1,
new ObjectType('Symfony\Component\Notifier\Recipient\RecipientInterface')
),
new AddParamTypeDeclaration(
'Symfony\Component\Notifier\Channel\ChannelInterface',
'notify',
1,
new ObjectType('Symfony\Component\Notifier\Recipient\RecipientInterface')
),
new AddParamTypeDeclaration(
'Symfony\Component\Notifier\Channel\ChannelInterface',
'supports',
1,
new ObjectType('Symfony\Component\Notifier\Recipient\RecipientInterface')
),
new AddParamTypeDeclaration(
'Symfony\Component\Notifier\Notification\ChatNotificationInterface',
'asChatMessage',
0,
new ObjectType('Symfony\Component\Notifier\Recipient\RecipientInterface')
),
new AddParamTypeDeclaration(
'Symfony\Component\Notifier\Notification\EmailNotificationInterface',
'asEmailMessage',
0,
new ObjectType('Symfony\Component\Notifier\Recipient\EmailRecipientInterface')
),
new AddParamTypeDeclaration(
'Symfony\Component\Notifier\Notification\SmsNotificationInterface',
'asSmsMessage',
0,
new ObjectType('Symfony\Component\Notifier\Recipient\SmsRecipientInterface')
),
]);
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

declare(strict_types=1);

use Rector\Config\RectorConfig;
use Rector\Symfony\Symfony52\Rector\New_\PropertyAccessorCreationBooleanToFlagsRector;

return static function (RectorConfig $rectorConfig): void {
$rectorConfig->rules([
// https://github.com/symfony/symfony/blob/5.x/UPGRADE-5.2.md#propertyaccess
PropertyAccessorCreationBooleanToFlagsRector::class,
]);
};
13 changes: 13 additions & 0 deletions config/sets/symfony/symfony5/symfony52/symfony52-property-info.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

declare(strict_types=1);

use Rector\Config\RectorConfig;
use Rector\Symfony\Symfony52\Rector\MethodCall\ReflectionExtractorEnableMagicCallExtractorRector;

return static function (RectorConfig $rectorConfig): void {
$rectorConfig->rules([
// https://github.com/symfony/symfony/blob/5.x/UPGRADE-5.2.md#propertyinfo
ReflectionExtractorEnableMagicCallExtractorRector::class,
]);
};
53 changes: 53 additions & 0 deletions config/sets/symfony/symfony5/symfony52/symfony52-security-core.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<?php

declare(strict_types=1);

use Rector\Config\RectorConfig;
use Rector\Renaming\Rector\MethodCall\RenameMethodRector;
use Rector\Renaming\ValueObject\MethodCallRename;

return static function (RectorConfig $rectorConfig): void {
$rectorConfig->ruleWithConfiguration(RenameMethodRector::class, [
new MethodCallRename(
'Symfony\Component\Security\Core\Authentication\Token\PreAuthenticatedToken',
'setProviderKey',
'setFirewallName'
),
new MethodCallRename(
'Symfony\Component\Security\Core\Authentication\Token\PreAuthenticatedToken',
'getProviderKey',
'getFirewallName'
),
new MethodCallRename(
'Symfony\Component\Security\Core\Authentication\Token\RememberMeToken',
'setProviderKey',
'setFirewallName'
),
new MethodCallRename(
'Symfony\Component\Security\Core\Authentication\Token\RememberMeToken',
'getProviderKey',
'getFirewallName'
),
new MethodCallRename(
'Symfony\Component\Security\Core\Authentication\Token\SwitchUserToken',
'setProviderKey',
'setFirewallName'
),
new MethodCallRename(
'Symfony\Component\Security\Core\Authentication\Token\SwitchUserToken',
'getProviderKey',
'getFirewallName'
),
new MethodCallRename(
'Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken',
'setProviderKey',
'setFirewallName'
),
new MethodCallRename(
'Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken',
'getProviderKey',
'getFirewallName'
),
]);

};
Loading
Loading