From 5e357ef42e8927d786304043a61e6e27e64cb10e Mon Sep 17 00:00:00 2001 From: TomasVotruba Date: Wed, 27 Jan 2021 14:51:23 +0100 Subject: [PATCH] make use of new RenameClassAndConstFetch() --- config/set/cakephp40.php | 29 +- config/set/nette-to-symfony.php | 337 +++++++++++------- config/set/symfony51.php | 40 ++- config/set/symfony52.php | 7 +- .../StaticCallToNewRectorTest.php | 3 +- 5 files changed, 256 insertions(+), 160 deletions(-) diff --git a/config/set/cakephp40.php b/config/set/cakephp40.php index 31952d702e71..5dd1b38db816 100644 --- a/config/set/cakephp40.php +++ b/config/set/cakephp40.php @@ -19,6 +19,7 @@ use Rector\Renaming\Rector\PropertyFetch\RenamePropertyRector; use Rector\Renaming\Rector\StaticCall\RenameStaticMethodRector; use Rector\Renaming\ValueObject\MethodCallRename; +use Rector\Renaming\ValueObject\RenameClassAndConstFetch; use Rector\Renaming\ValueObject\RenameClassConstFetch; use Rector\Renaming\ValueObject\RenameProperty; use Rector\Renaming\ValueObject\RenameStaticMethod; @@ -47,10 +48,30 @@ RenameClassConstFetchRector::CLASS_CONSTANT_RENAME => ValueObjectInliner::inline([ new RenameClassConstFetch('Cake\View\View', 'NAME_ELEMENT', 'TYPE_ELEMENT'), new RenameClassConstFetch('Cake\View\View', 'NAME_LAYOUT', 'TYPE_LAYOUT'), - new RenameClassConstFetch('Cake\Mailer\Email', 'MESSAGE_HTML', 'Cake\Mailer\Message::MESSAGE_HTML'), - new RenameClassConstFetch('Cake\Mailer\Email', 'MESSAGE_TEXT', 'Cake\Mailer\Message::MESSAGE_TEXT'), - new RenameClassConstFetch('Cake\Mailer\Email', 'MESSAGE_BOTH', 'Cake\Mailer\Message::MESSAGE_BOTH'), - new RenameClassConstFetch('Cake\Mailer\Email', 'EMAIL_PATTERN', 'Cake\Mailer\Message::EMAIL_PATTERN'), + new RenameClassAndConstFetch( + 'Cake\Mailer\Email', + 'MESSAGE_HTML', + 'Cake\Mailer\Message', + 'MESSAGE_HTML' + ), + new RenameClassAndConstFetch( + 'Cake\Mailer\Email', + 'MESSAGE_TEXT', + 'Cake\Mailer\Message', + 'MESSAGE_TEXT' + ), + new RenameClassAndConstFetch( + 'Cake\Mailer\Email', + 'MESSAGE_BOTH', + 'Cake\Mailer\Message', + 'MESSAGE_BOTH' + ), + new RenameClassAndConstFetch( + 'Cake\Mailer\Email', + 'EMAIL_PATTERN', + 'Cake\Mailer\Message', + 'EMAIL_PATTERN' + ), ]), ]]); diff --git a/config/set/nette-to-symfony.php b/config/set/nette-to-symfony.php index 9496336300ac..6aa3343661c8 100644 --- a/config/set/nette-to-symfony.php +++ b/config/set/nette-to-symfony.php @@ -14,7 +14,7 @@ use Rector\Renaming\Rector\MethodCall\RenameMethodRector; use Rector\Renaming\Rector\Name\RenameClassRector; use Rector\Renaming\ValueObject\MethodCallRename; -use Rector\Renaming\ValueObject\RenameClassConstFetch; +use Rector\Renaming\ValueObject\RenameClassAndConstFetch; use Rector\TypeDeclaration\Rector\ClassMethod\AddReturnTypeDeclarationRector; use Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration; use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator; @@ -73,340 +73,407 @@ $services->set(RenameClassConstFetchRector::class) ->call('configure', [[ RenameClassConstFetchRector::CLASS_CONSTANT_RENAME => ValueObjectInliner::inline([ - new RenameClassConstFetch( + new RenameClassAndConstFetch( 'Nette\Http\*Response', 'S100_CONTINUE', - 'Symfony\Component\HttpFoundation\Response::HTTP_CONTINUE' + 'Symfony\Component\HttpFoundation\Response', + 'HTTP_CONTINUE' ), - new RenameClassConstFetch( + new RenameClassAndConstFetch( 'Nette\Http\*Response', 'S101_SWITCHING_PROTOCOLS', - 'Symfony\Component\HttpFoundation\Response::HTTP_SWITCHING_PROTOCOLS' + 'Symfony\Component\HttpFoundation\Response', + 'HTTP_SWITCHING_PROTOCOLS' ), - new RenameClassConstFetch( + new RenameClassAndConstFetch( 'Nette\Http\*Response', 'S102_PROCESSING', - 'Symfony\Component\HttpFoundation\Response::HTTP_PROCESSING' + 'Symfony\Component\HttpFoundation\Response', + 'HTTP_PROCESSING' ), - new RenameClassConstFetch( + new RenameClassAndConstFetch( 'Nette\Http\*Response', 'S200_OK', - 'Symfony\Component\HttpFoundation\Response::HTTP_OK' + 'Symfony\Component\HttpFoundation\Response', + 'HTTP_OK' ), - new RenameClassConstFetch( + new RenameClassAndConstFetch( 'Nette\Http\*Response', 'S201_CREATED', - 'Symfony\Component\HttpFoundation\Response::HTTP_CREATED' + 'Symfony\Component\HttpFoundation\Response', + 'HTTP_CREATED' ), - new RenameClassConstFetch( + new RenameClassAndConstFetch( 'Nette\Http\*Response', 'S202_ACCEPTED', - 'Symfony\Component\HttpFoundation\Response::HTTP_ACCEPTED' + 'Symfony\Component\HttpFoundation\Response', + 'HTTP_ACCEPTED' ), - new RenameClassConstFetch( + new RenameClassAndConstFetch( 'Nette\Http\*Response', 'S203_NON_AUTHORITATIVE_INFORMATION', - 'Symfony\Component\HttpFoundation\Response::HTTP_NON_AUTHORITATIVE_INFORMATION' + 'Symfony\Component\HttpFoundation\Response', + 'HTTP_NON_AUTHORITATIVE_INFORMATION' ), - new RenameClassConstFetch( + new RenameClassAndConstFetch( 'Nette\Http\*Response', 'S204_NO_CONTENT', - 'Symfony\Component\HttpFoundation\Response::HTTP_NO_CONTENT' + 'Symfony\Component\HttpFoundation\Response', + 'HTTP_NO_CONTENT' ), - new RenameClassConstFetch( + new RenameClassAndConstFetch( 'Nette\Http\*Response', 'S205_RESET_CONTENT', - 'Symfony\Component\HttpFoundation\Response::HTTP_RESET_CONTENT' + 'Symfony\Component\HttpFoundation\Response', + 'HTTP_RESET_CONTENT' ), - new RenameClassConstFetch( + new RenameClassAndConstFetch( 'Nette\Http\*Response', 'S206_PARTIAL_CONTENT', - 'Symfony\Component\HttpFoundation\Response::HTTP_PARTIAL_CONTENT' + 'Symfony\Component\HttpFoundation\Response', + 'HTTP_PARTIAL_CONTENT' ), - new RenameClassConstFetch( + new RenameClassAndConstFetch( 'Nette\Http\*Response', 'S207_MULTI_STATUS', - 'Symfony\Component\HttpFoundation\Response::HTTP_MULTI_STATUS' + 'Symfony\Component\HttpFoundation\Response', + 'HTTP_MULTI_STATUS' ), - new RenameClassConstFetch( + new RenameClassAndConstFetch( 'Nette\Http\*Response', 'S208_ALREADY_REPORTED', - 'Symfony\Component\HttpFoundation\Response::HTTP_ALREADY_REPORTED' + 'Symfony\Component\HttpFoundation\Response', + 'HTTP_ALREADY_REPORTED' ), - new RenameClassConstFetch( + new RenameClassAndConstFetch( 'Nette\Http\*Response', 'S226_IM_USED', - 'Symfony\Component\HttpFoundation\Response::HTTP_IM_USED' + 'Symfony\Component\HttpFoundation\Response', + 'HTTP_IM_USED' ), - new RenameClassConstFetch( + new RenameClassAndConstFetch( 'Nette\Http\*Response', 'S300_MULTIPLE_CHOICES', - 'Symfony\Component\HttpFoundation\Response::HTTP_MULTIPLE_CHOICES' + 'Symfony\Component\HttpFoundation\Response', + 'HTTP_MULTIPLE_CHOICES' ), - new RenameClassConstFetch( + new RenameClassAndConstFetch( 'Nette\Http\*Response', 'S301_MOVED_PERMANENTLY', - 'Symfony\Component\HttpFoundation\Response::HTTP_MOVED_PERMANENTLY' + 'Symfony\Component\HttpFoundation\Response', + 'HTTP_MOVED_PERMANENTLY' ), - new RenameClassConstFetch( + new RenameClassAndConstFetch( 'Nette\Http\*Response', 'S302_FOUND', - 'Symfony\Component\HttpFoundation\Response::HTTP_FOUND' + 'Symfony\Component\HttpFoundation\Response', + 'HTTP_FOUND' ), - new RenameClassConstFetch( + new RenameClassAndConstFetch( 'Nette\Http\*Response', 'S303_SEE_OTHER', - 'Symfony\Component\HttpFoundation\Response::HTTP_SEE_OTHER' + 'Symfony\Component\HttpFoundation\Response', + 'HTTP_SEE_OTHER' ), - new RenameClassConstFetch( + new RenameClassAndConstFetch( 'Nette\Http\*Response', 'S303_POST_GET', - 'Symfony\Component\HttpFoundation\Response::HTTP_SEE_OTHER' + 'Symfony\Component\HttpFoundation\Response', + 'HTTP_SEE_OTHER' ), - new RenameClassConstFetch( + new RenameClassAndConstFetch( 'Nette\Http\*Response', 'S304_NOT_MODIFIED', - 'Symfony\Component\HttpFoundation\Response::HTTP_NOT_MODIFIED' + 'Symfony\Component\HttpFoundation\Response', + 'HTTP_NOT_MODIFIED' ), - new RenameClassConstFetch( + new RenameClassAndConstFetch( 'Nette\Http\*Response', 'S305_USE_PROXY', - 'Symfony\Component\HttpFoundation\Response::HTTP_USE_PROXY' + 'Symfony\Component\HttpFoundation\Response', + 'HTTP_USE_PROXY' ), - new RenameClassConstFetch( + new RenameClassAndConstFetch( 'Nette\Http\*Response', 'S307_TEMPORARY_REDIRECT', - 'Symfony\Component\HttpFoundation\Response::HTTP_TEMPORARY_REDIRECT' + 'Symfony\Component\HttpFoundation\Response', + 'HTTP_TEMPORARY_REDIRECT' ), - new RenameClassConstFetch( + new RenameClassAndConstFetch( 'Nette\Http\*Response', 'S308_PERMANENT_REDIRECT', - 'Symfony\Component\HttpFoundation\Response::HTTP_PERMANENTLY_REDIRECT' + 'Symfony\Component\HttpFoundation\Response', + 'HTTP_PERMANENTLY_REDIRECT' ), - new RenameClassConstFetch( + new RenameClassAndConstFetch( 'Nette\Http\*Response', 'S400_BAD_REQUEST', - 'Symfony\Component\HttpFoundation\Response::HTTP_BAD_REQUEST' + 'Symfony\Component\HttpFoundation\Response', + 'HTTP_BAD_REQUEST' ), - new RenameClassConstFetch( + new RenameClassAndConstFetch( 'Nette\Http\*Response', 'S401_UNAUTHORIZED', - 'Symfony\Component\HttpFoundation\Response::HTTP_UNAUTHORIZED' + 'Symfony\Component\HttpFoundation\Response', + 'HTTP_UNAUTHORIZED' ), - new RenameClassConstFetch( + new RenameClassAndConstFetch( 'Nette\Http\*Response', 'S402_PAYMENT_REQUIRED', - 'Symfony\Component\HttpFoundation\Response::HTTP_PAYMENT_REQUIRED' + 'Symfony\Component\HttpFoundation\Response', + 'HTTP_PAYMENT_REQUIRED' ), - new RenameClassConstFetch( + new RenameClassAndConstFetch( 'Nette\Http\*Response', 'S403_FORBIDDEN', - 'Symfony\Component\HttpFoundation\Response::HTTP_FORBIDDEN' + 'Symfony\Component\HttpFoundation\Response', + 'HTTP_FORBIDDEN' ), - new RenameClassConstFetch( + new RenameClassAndConstFetch( 'Nette\Http\*Response', 'S404_NOT_FOUND', - 'Symfony\Component\HttpFoundation\Response::HTTP_NOT_FOUND' + 'Symfony\Component\HttpFoundation\Response', + 'HTTP_NOT_FOUND' ), - new RenameClassConstFetch( + new RenameClassAndConstFetch( 'Nette\Http\*Response', 'S405_METHOD_NOT_ALLOWED', - 'Symfony\Component\HttpFoundation\Response::HTTP_METHOD_NOT_ALLOWED' + 'Symfony\Component\HttpFoundation\Response', + 'HTTP_METHOD_NOT_ALLOWED' ), - new RenameClassConstFetch( + new RenameClassAndConstFetch( 'Nette\Http\*Response', 'S406_NOT_ACCEPTABLE', - 'Symfony\Component\HttpFoundation\Response::HTTP_NOT_ACCEPTABLE' + 'Symfony\Component\HttpFoundation\Response', + 'HTTP_NOT_ACCEPTABLE' ), - new RenameClassConstFetch( + new RenameClassAndConstFetch( 'Nette\Http\*Response', 'S407_PROXY_AUTHENTICATION_REQUIRED', - 'Symfony\Component\HttpFoundation\Response::HTTP_PROXY_AUTHENTICATION_REQUIRED' + 'Symfony\Component\HttpFoundation\Response', + 'HTTP_PROXY_AUTHENTICATION_REQUIRED' ), - new RenameClassConstFetch( + new RenameClassAndConstFetch( 'Nette\Http\*Response', 'S408_REQUEST_TIMEOUT', - 'Symfony\Component\HttpFoundation\Response::HTTP_REQUEST_TIMEOUT' + 'Symfony\Component\HttpFoundation\Response', + 'HTTP_REQUEST_TIMEOUT' ), - new RenameClassConstFetch( + new RenameClassAndConstFetch( 'Nette\Http\*Response', 'S409_CONFLICT', - 'Symfony\Component\HttpFoundation\Response::HTTP_CONFLICT' + 'Symfony\Component\HttpFoundation\Response', + 'HTTP_CONFLICT' ), - new RenameClassConstFetch( + new RenameClassAndConstFetch( 'Nette\Http\*Response', 'S410_GONE', - 'Symfony\Component\HttpFoundation\Response::HTTP_GONE' + 'Symfony\Component\HttpFoundation\Response', + 'HTTP_GONE' ), - new RenameClassConstFetch( + new RenameClassAndConstFetch( 'Nette\Http\*Response', 'S411_LENGTH_REQUIRED', - 'Symfony\Component\HttpFoundation\Response::HTTP_LENGTH_REQUIRED' + 'Symfony\Component\HttpFoundation\Response', + 'HTTP_LENGTH_REQUIRED' ), - new RenameClassConstFetch( + new RenameClassAndConstFetch( 'Nette\Http\*Response', 'S412_PRECONDITION_FAILED', - 'Symfony\Component\HttpFoundation\Response::HTTP_PRECONDITION_FAILED' + 'Symfony\Component\HttpFoundation\Response', + 'HTTP_PRECONDITION_FAILED' ), - new RenameClassConstFetch( + new RenameClassAndConstFetch( 'Nette\Http\*Response', 'S413_REQUEST_ENTITY_TOO_LARGE', - 'Symfony\Component\HttpFoundation\Response::HTTP_REQUEST_ENTITY_TOO_LARGE' + 'Symfony\Component\HttpFoundation\Response', + 'HTTP_REQUEST_ENTITY_TOO_LARGE' ), - new RenameClassConstFetch( + new RenameClassAndConstFetch( 'Nette\Http\*Response', 'S414_REQUEST_URI_TOO_LONG', - 'Symfony\Component\HttpFoundation\Response::HTTP_REQUEST_URI_TOO_LONG' + 'Symfony\Component\HttpFoundation\Response', + 'HTTP_REQUEST_URI_TOO_LONG' ), - new RenameClassConstFetch( + new RenameClassAndConstFetch( 'Nette\Http\*Response', 'S415_UNSUPPORTED_MEDIA_TYPE', - 'Symfony\Component\HttpFoundation\Response::HTTP_UNSUPPORTED_MEDIA_TYPE' + 'Symfony\Component\HttpFoundation\Response', + 'HTTP_UNSUPPORTED_MEDIA_TYPE' ), - new RenameClassConstFetch( + new RenameClassAndConstFetch( 'Nette\Http\*Response', 'S416_REQUESTED_RANGE_NOT_SATISFIABLE', - 'Symfony\Component\HttpFoundation\Response::HTTP_REQUESTED_RANGE_NOT_SATISFIABLE' + 'Symfony\Component\HttpFoundation\Response', + 'HTTP_REQUESTED_RANGE_NOT_SATISFIABLE' ), - new RenameClassConstFetch( + new RenameClassAndConstFetch( 'Nette\Http\*Response', 'S417_EXPECTATION_FAILED', - 'Symfony\Component\HttpFoundation\Response::HTTP_EXPECTATION_FAILED' + 'Symfony\Component\HttpFoundation\Response', + 'HTTP_EXPECTATION_FAILED' ), - new RenameClassConstFetch( + new RenameClassAndConstFetch( 'Nette\Http\*Response', 'S421_MISDIRECTED_REQUEST', - 'Symfony\Component\HttpFoundation\Response::HTTP_MISDIRECTED_REQUEST' + 'Symfony\Component\HttpFoundation\Response', + 'HTTP_MISDIRECTED_REQUEST' ), - new RenameClassConstFetch( + new RenameClassAndConstFetch( 'Nette\Http\*Response', 'S422_UNPROCESSABLE_ENTITY', - 'Symfony\Component\HttpFoundation\Response::HTTP_UNPROCESSABLE_ENTITY' + 'Symfony\Component\HttpFoundation\Response', + 'HTTP_UNPROCESSABLE_ENTITY' ), - new RenameClassConstFetch( + new RenameClassAndConstFetch( 'Nette\Http\*Response', 'S423_LOCKED', - 'Symfony\Component\HttpFoundation\Response::HTTP_LOCKED' + 'Symfony\Component\HttpFoundation\Response', + 'HTTP_LOCKED' ), - new RenameClassConstFetch( + new RenameClassAndConstFetch( 'Nette\Http\*Response', 'S424_FAILED_DEPENDENCY', - 'Symfony\Component\HttpFoundation\Response::HTTP_FAILED_DEPENDENCY' + 'Symfony\Component\HttpFoundation\Response', + 'HTTP_FAILED_DEPENDENCY' ), - new RenameClassConstFetch( + new RenameClassAndConstFetch( 'Nette\Http\*Response', 'S426_UPGRADE_REQUIRED', - 'Symfony\Component\HttpFoundation\Response::HTTP_UPGRADE_REQUIRED' + 'Symfony\Component\HttpFoundation\Response', + 'HTTP_UPGRADE_REQUIRED' ), - new RenameClassConstFetch( + new RenameClassAndConstFetch( 'Nette\Http\*Response', 'S428_PRECONDITION_REQUIRED', - 'Symfony\Component\HttpFoundation\Response::HTTP_PRECONDITION_REQUIRED' + 'Symfony\Component\HttpFoundation\Response', + 'HTTP_PRECONDITION_REQUIRED' ), - new RenameClassConstFetch( + new RenameClassAndConstFetch( 'Nette\Http\*Response', 'S429_TOO_MANY_REQUESTS', - 'Symfony\Component\HttpFoundation\Response::HTTP_TOO_MANY_REQUESTS' + 'Symfony\Component\HttpFoundation\Response', + 'HTTP_TOO_MANY_REQUESTS' ), - new RenameClassConstFetch( + new RenameClassAndConstFetch( 'Nette\Http\*Response', 'S431_REQUEST_HEADER_FIELDS_TOO_LARGE', - 'Symfony\Component\HttpFoundation\Response::HTTP_REQUEST_HEADER_FIELDS_TOO_LARGE' + 'Symfony\Component\HttpFoundation\Response', + 'HTTP_REQUEST_HEADER_FIELDS_TOO_LARGE' ), - new RenameClassConstFetch( + new RenameClassAndConstFetch( 'Nette\Http\*Response', 'S451_UNAVAILABLE_FOR_LEGAL_REASONS', - 'Symfony\Component\HttpFoundation\Response::HTTP_UNAVAILABLE_FOR_LEGAL_REASONS' + 'Symfony\Component\HttpFoundation\Response', + 'HTTP_UNAVAILABLE_FOR_LEGAL_REASONS' ), - new RenameClassConstFetch( + new RenameClassAndConstFetch( 'Nette\Http\*Response', 'S500_INTERNAL_SERVER_ERROR', - 'Symfony\Component\HttpFoundation\Response::HTTP_INTERNAL_SERVER_ERROR' + 'Symfony\Component\HttpFoundation\Response', + 'HTTP_INTERNAL_SERVER_ERROR' ), - new RenameClassConstFetch( + new RenameClassAndConstFetch( 'Nette\Http\*Response', 'S501_NOT_IMPLEMENTED', - 'Symfony\Component\HttpFoundation\Response::HTTP_NOT_IMPLEMENTED' + 'Symfony\Component\HttpFoundation\Response', + 'HTTP_NOT_IMPLEMENTED' ), - new RenameClassConstFetch( + new RenameClassAndConstFetch( 'Nette\Http\*Response', 'S502_BAD_GATEWAY', - 'Symfony\Component\HttpFoundation\Response::HTTP_BAD_GATEWAY' + 'Symfony\Component\HttpFoundation\Response', + 'HTTP_BAD_GATEWAY' ), - new RenameClassConstFetch( + new RenameClassAndConstFetch( 'Nette\Http\*Response', 'S503_SERVICE_UNAVAILABLE', - 'Symfony\Component\HttpFoundation\Response::HTTP_SERVICE_UNAVAILABLE' + 'Symfony\Component\HttpFoundation\Response', + 'HTTP_SERVICE_UNAVAILABLE' ), - new RenameClassConstFetch( + new RenameClassAndConstFetch( 'Nette\Http\*Response', 'S504_GATEWAY_TIMEOUT', - 'Symfony\Component\HttpFoundation\Response::HTTP_GATEWAY_TIMEOUT' + 'Symfony\Component\HttpFoundation\Response', + 'HTTP_GATEWAY_TIMEOUT' ), - new RenameClassConstFetch( + new RenameClassAndConstFetch( 'Nette\Http\*Response', 'S505_HTTP_VERSION_NOT_SUPPORTED', - 'Symfony\Component\HttpFoundation\Response::HTTP_VERSION_NOT_SUPPORTED' + 'Symfony\Component\HttpFoundation\Response', + 'HTTP_VERSION_NOT_SUPPORTED' ), - new RenameClassConstFetch( + new RenameClassAndConstFetch( 'Nette\Http\*Response', 'S506_VARIANT_ALSO_NEGOTIATES', - 'Symfony\Component\HttpFoundation\Response::HTTP_VARIANT_ALSO_NEGOTIATES_EXPERIMENTAL' + 'Symfony\Component\HttpFoundation\Response', + 'HTTP_VARIANT_ALSO_NEGOTIATES_EXPERIMENTAL' ), - new RenameClassConstFetch( + new RenameClassAndConstFetch( 'Nette\Http\*Response', 'S507_INSUFFICIENT_STORAGE', - 'Symfony\Component\HttpFoundation\Response::HTTP_INSUFFICIENT_STORAGE' + 'Symfony\Component\HttpFoundation\Response', + 'HTTP_INSUFFICIENT_STORAGE' ), - new RenameClassConstFetch( + new RenameClassAndConstFetch( 'Nette\Http\*Response', 'S508_LOOP_DETECTED', - 'Symfony\Component\HttpFoundation\Response::HTTP_LOOP_DETECTED' + 'Symfony\Component\HttpFoundation\Response', + 'HTTP_LOOP_DETECTED' ), - new RenameClassConstFetch( + new RenameClassAndConstFetch( 'Nette\Http\*Response', 'S510_NOT_EXTENDED', - 'Symfony\Component\HttpFoundation\Response::HTTP_NOT_EXTENDED' + 'Symfony\Component\HttpFoundation\Response', + 'HTTP_NOT_EXTENDED' ), - new RenameClassConstFetch( + new RenameClassAndConstFetch( 'Nette\Http\*Response', 'S511_NETWORK_AUTHENTICATION_REQUIRED', - 'Symfony\Component\HttpFoundation\Response::HTTP_NETWORK_AUTHENTICATION_REQUIRED' + 'Symfony\Component\HttpFoundation\Response', + 'HTTP_NETWORK_AUTHENTICATION_REQUIRED' ), - new RenameClassConstFetch( + new RenameClassAndConstFetch( 'Nette\Http\*Request', 'GET', - 'Symfony\Component\HttpFoundation\Request::METHOD_GET' + 'Symfony\Component\HttpFoundation\Request', + 'METHOD_GET' ), - new RenameClassConstFetch( + new RenameClassAndConstFetch( 'Nette\Http\*Request', 'POST', - 'Symfony\Component\HttpFoundation\Request::METHOD_POST' + 'Symfony\Component\HttpFoundation\Request', + 'METHOD_POST' ), - new RenameClassConstFetch( + new RenameClassAndConstFetch( 'Nette\Http\*Request', 'HEAD', - 'Symfony\Component\HttpFoundation\Request::METHOD_HEAD' + 'Symfony\Component\HttpFoundation\Request', + 'METHOD_HEAD' ), - new RenameClassConstFetch( + new RenameClassAndConstFetch( 'Nette\Http\*Request', 'PUT', - 'Symfony\Component\HttpFoundation\Request::METHOD_PUT' + 'Symfony\Component\HttpFoundation\Request', + 'METHOD_PUT' ), - new RenameClassConstFetch( + new RenameClassAndConstFetch( 'Nette\Http\*Request', 'DELETE', - 'Symfony\Component\HttpFoundation\Request::METHOD_DELETE' + 'Symfony\Component\HttpFoundation\Request', + 'METHOD_DELETE' ), - new RenameClassConstFetch( + new RenameClassAndConstFetch( 'Nette\Http\*Request', 'PATCH', - 'Symfony\Component\HttpFoundation\Request::METHOD_PATCH' + 'Symfony\Component\HttpFoundation\Request', + 'METHOD_PATCH' ), - new RenameClassConstFetch( + new RenameClassAndConstFetch( 'Nette\Http\*Request', 'OPTIONS', - 'Symfony\Component\HttpFoundation\Request::METHOD_OPTIONS' + 'Symfony\Component\HttpFoundation\Request', + 'METHOD_OPTIONS' ), ]), ]]); diff --git a/config/set/symfony51.php b/config/set/symfony51.php index 8348f3ddc97e..e57bf1fc0b29 100644 --- a/config/set/symfony51.php +++ b/config/set/symfony51.php @@ -8,7 +8,7 @@ use Rector\Renaming\Rector\MethodCall\RenameMethodRector; use Rector\Renaming\Rector\Name\RenameClassRector; use Rector\Renaming\ValueObject\MethodCallRename; -use Rector\Renaming\ValueObject\RenameClassConstFetch; +use Rector\Renaming\ValueObject\RenameClassAndConstFetch; use Rector\Transform\Rector\New_\NewArgToMethodCallRector; use Rector\Transform\Rector\StaticCall\StaticCallToNewRector; use Rector\Transform\ValueObject\NewArgToMethodCall; @@ -27,8 +27,7 @@ ->call('configure', [[ RenameClassRector::OLD_TO_NEW_CLASSES => [ 'Symfony\Component\EventDispatcher\LegacyEventDispatcherProxy' => 'Symfony\Component\EventDispatcher\EventDispatcherInterface', - 'Symfony\Component\Form\Extension\Validator\Util\ServerParams' => [ - 'Symfony\Component\Form\Util\ServerParams', + 'Symfony\Component\Form\Extension\Validator\Util\ServerParams' => 'Symfony\Component\Form\Util\ServerParams', ], ], ]]); @@ -73,40 +72,47 @@ $services->set(RenameClassConstFetchRector::class) ->call('configure', [[ RenameClassConstFetchRector::CLASS_CONSTANT_RENAME => ValueObjectInliner::inline([ - new RenameClassConstFetch( + new RenameClassAndConstFetch( 'Symfony\Component\Form\Extension\Core\DataTransformer\NumberToLocalizedStringTransformer', 'ROUND_FLOOR', - 'NumberFormatter::ROUND_FLOOR' + 'NumberFormatter', + 'ROUND_FLOOR' ), - new RenameClassConstFetch( + new RenameClassAndConstFetch( 'Symfony\Component\Form\Extension\Core\DataTransformer\NumberToLocalizedStringTransformer', 'ROUND_DOWN', - 'NumberFormatter::ROUND_DOWN' + 'NumberFormatter', + 'ROUND_DOWN' ), - new RenameClassConstFetch( + new RenameClassAndConstFetch( 'Symfony\Component\Form\Extension\Core\DataTransformer\NumberToLocalizedStringTransformer', 'ROUND_HALF_DOWN', - 'NumberFormatter::ROUND_HALFDOWN' + 'NumberFormatter', + 'ROUND_HALFDOWN' ), - new RenameClassConstFetch( + new RenameClassAndConstFetch( 'Symfony\Component\Form\Extension\Core\DataTransformer\NumberToLocalizedStringTransformer', 'ROUND_HALF_EVEN', - 'NumberFormatter::ROUND_HALFEVEN' + 'NumberFormatter', + 'ROUND_HALFEVEN' ), - new RenameClassConstFetch( + new RenameClassAndConstFetch( 'Symfony\Component\Form\Extension\Core\DataTransformer\NumberToLocalizedStringTransformer', 'ROUND_HALFUP', - 'NumberFormatter::ROUND_HALFUP' + 'NumberFormatter', + 'ROUND_HALFUP' ), - new RenameClassConstFetch( + new RenameClassAndConstFetch( 'Symfony\Component\Form\Extension\Core\DataTransformer\NumberToLocalizedStringTransformer', 'ROUND_UP', - 'NumberFormatter::ROUND_UP' + 'NumberFormatter', + 'ROUND_UP' ), - new RenameClassConstFetch( + new RenameClassAndConstFetch( 'Symfony\Component\Form\Extension\Core\DataTransformer\NumberToLocalizedStringTransformer', 'ROUND_CEILING', - 'NumberFormatter::ROUND_CEILING' + 'NumberFormatter', + 'ROUND_CEILING' ), ]), ]]); diff --git a/config/set/symfony52.php b/config/set/symfony52.php index 9ce9599271f7..1cd4ccc1daba 100644 --- a/config/set/symfony52.php +++ b/config/set/symfony52.php @@ -5,7 +5,7 @@ use Rector\Renaming\Rector\ClassConstFetch\RenameClassConstFetchRector; use Rector\Renaming\Rector\MethodCall\RenameMethodRector; use Rector\Renaming\ValueObject\MethodCallRename; -use Rector\Renaming\ValueObject\RenameClassConstFetch; +use Rector\Renaming\ValueObject\RenameClassAndConstFetch; use Rector\Symfony5\Rector\MethodCall\DefinitionAliasSetPrivateToSetPublicRector; use Rector\Symfony5\Rector\MethodCall\ReflectionExtractorEnableMagicCallExtractorRector; use Rector\Symfony5\Rector\New_\PropertyAccessorCreationBooleanToFlagsRector; @@ -45,10 +45,11 @@ $services->set(RenameClassConstFetchRector::class) ->call('configure', [[ RenameClassConstFetchRector::CLASS_CONSTANT_RENAME => ValueObjectInliner::inline([ - new RenameClassConstFetch( + new RenameClassAndConstFetch( 'Symfony\Component\Security\Http\Firewall\AccessListener', 'PUBLIC_ACCESS', - 'Symfony\Component\Security\Core\Authorization\Voter\AuthenticatedVoter::PUBLIC_ACCESS' + 'Symfony\Component\Security\Core\Authorization\Voter\AuthenticatedVoter', + 'PUBLIC_ACCESS' ), ]), ]]); diff --git a/rules/transform/tests/Rector/StaticCall/StaticCallToNewRector/StaticCallToNewRectorTest.php b/rules/transform/tests/Rector/StaticCall/StaticCallToNewRector/StaticCallToNewRectorTest.php index 63962c9d703f..b2fa1bedd81b 100644 --- a/rules/transform/tests/Rector/StaticCall/StaticCallToNewRector/StaticCallToNewRectorTest.php +++ b/rules/transform/tests/Rector/StaticCall/StaticCallToNewRector/StaticCallToNewRectorTest.php @@ -6,6 +6,7 @@ use Rector\Testing\PHPUnit\AbstractRectorTestCase; use Rector\Transform\Tests\Rector\StaticCall\StaticCallToNewRector\Source\SomeJsonResponse; +use Rector\Transform\ValueObject\StaticCallToNew; final class StaticCallToNewRectorTest extends AbstractRectorTestCase { @@ -31,7 +32,7 @@ protected function getRectorsWithConfiguration(): array \Rector\Transform\Rector\StaticCall\StaticCallToNewRector::class => [ \Rector\Transform\Rector\StaticCall\StaticCallToNewRector::STATIC_CALLS_TO_NEWS => [ - SomeJsonResponse::class => 'create', + new StaticCallToNew(SomeJsonResponse::class, 'create'), ], ], ];