From 54a060279747051d0dca2510e238072df74d1a91 Mon Sep 17 00:00:00 2001 From: bjorn Date: Fri, 7 Nov 2025 20:46:05 +0100 Subject: [PATCH] build: fix codestyle --- .../AnnotationToAttributeRector.php | 6 +- .../Deprecation/SystemTimeZonesRector.php | 6 +- .../VersionedFunctionToServiceRector.php | 6 +- .../Deprecation/WatchdogExceptionRector.php | 6 +- src/Drupal8/Rector/Deprecation/DBRector.php | 30 ++---- .../Rector/Deprecation/DrupalLRector.php | 3 +- .../Deprecation/DrupalServiceRenameRector.php | 6 +- .../Deprecation/DrupalSetMessageRector.php | 3 +- .../Rector/Deprecation/DrupalURLRector.php | 3 +- .../Rector/Deprecation/EntityCreateRector.php | 3 +- .../EntityDeleteMultipleRector.php | 3 +- .../Deprecation/EntityInterfaceLinkRector.php | 3 +- .../Rector/Deprecation/EntityLoadRector.php | 6 +- .../Deprecation/EntityManagerRector.php | 7 +- .../Rector/Deprecation/EntityViewRector.php | 3 +- .../Deprecation/FileDefaultSchemeRector.php | 3 +- ...nctionalTestDefaultThemePropertyRector.php | 4 +- .../Rector/Deprecation/GetMockRector.php | 6 +- .../Deprecation/LinkGeneratorTraitLRector.php | 3 +- .../Deprecation/RequestTimeConstRector.php | 3 +- .../Deprecation/SafeMarkupFormatRector.php | 3 +- .../Deprecation/StaticToFunctionRector.php | 18 ++-- .../Deprecation/AssertFieldByIdRector.php | 3 +- .../Deprecation/AssertFieldByNameRector.php | 3 +- .../Deprecation/AssertLegacyTraitRector.php | 72 +++++--------- .../Deprecation/AssertNoFieldByIdRector.php | 3 +- .../Deprecation/AssertNoFieldByNameRector.php | 3 +- .../Deprecation/AssertNoUniqueTextRector.php | 3 +- .../AssertOptionSelectedRector.php | 3 +- .../Deprecation/ConstructFieldXpathRector.php | 3 +- .../Deprecation/ExtensionPathRector.php | 12 +-- .../Rector/Deprecation/FileBuildUriRector.php | 3 +- .../Deprecation/FileCreateUrlRector.php | 3 +- .../FileUrlTransformRelativeRector.php | 3 +- .../Rector/Deprecation/FromUriRector.php | 3 +- .../FunctionToEntityTypeStorageMethod.php | 6 +- .../FunctionToFirstArgMethodRector.php | 6 +- .../Deprecation/GetAllOptionsRector.php | 3 +- .../Deprecation/GetRawContentRector.php | 3 +- .../Rector/Deprecation/ModuleLoadRector.php | 3 +- src/Drupal9/Rector/Deprecation/PassRector.php | 3 +- .../SystemSortByInfoNameRector.php | 3 +- .../TaxonomyTermLoadMultipleByNameRector.php | 3 +- ...abularyGetNamesDrupalStaticResetRector.php | 3 +- .../TaxonomyVocabularyGetNamesRector.php | 3 +- .../UiHelperTraitDrupalPostFormRector.php | 3 +- .../Rector/Deprecation/UserPasswordRector.php | 3 +- .../ProtectedStaticModulesPropertyRector.php | 4 +- src/Rector/Convert/HookConvertRector.php | 25 +++-- .../ClassConstantToClassConstantRector.php | 6 +- .../ConstantToClassConstantRector.php | 6 +- .../DeprecationHelperRemoveRector.php | 6 +- .../Deprecation/FunctionToServiceRector.php | 96 +++++++------------ .../Deprecation/FunctionToStaticRector.php | 18 ++-- .../MethodToMethodWithCheckRector.php | 18 ++-- .../PHPUnit/ShouldCallParentMethodsRector.php | 7 +- 56 files changed, 164 insertions(+), 315 deletions(-) diff --git a/src/Drupal10/Rector/Deprecation/AnnotationToAttributeRector.php b/src/Drupal10/Rector/Deprecation/AnnotationToAttributeRector.php index 7497fd53..403c5416 100644 --- a/src/Drupal10/Rector/Deprecation/AnnotationToAttributeRector.php +++ b/src/Drupal10/Rector/Deprecation/AnnotationToAttributeRector.php @@ -96,8 +96,7 @@ public function getRuleDefinition(): RuleDefinition * ) */ class PublishAction extends EntityActionBase { -CODE_SAMPLE - , <<<'CODE_SAMPLE' +CODE_SAMPLE, <<<'CODE_SAMPLE' namespace Drupal\Core\Action\Plugin\Action; @@ -115,8 +114,7 @@ class PublishAction extends EntityActionBase { deriver: EntityPublishedActionDeriver::class )] class PublishAction extends EntityActionBase { -CODE_SAMPLE - , +CODE_SAMPLE, [ new AnnotationToAttributeConfiguration('10.2.0', '12.0.0', 'Action', 'Drupal\Core\Action\Attribute\Action'), ])]); diff --git a/src/Drupal10/Rector/Deprecation/SystemTimeZonesRector.php b/src/Drupal10/Rector/Deprecation/SystemTimeZonesRector.php index 8299e6b2..7e13ddc2 100644 --- a/src/Drupal10/Rector/Deprecation/SystemTimeZonesRector.php +++ b/src/Drupal10/Rector/Deprecation/SystemTimeZonesRector.php @@ -86,15 +86,13 @@ public function getRuleDefinition(): RuleDefinition system_time_zones(FALSE, TRUE); system_time_zones(NULL, FALSE); system_time_zones(TRUE, FALSE); -CODE_BEFORE - , +CODE_BEFORE, <<<'CODE_AFTER' \Drupal\Core\Datetime\TimeZoneFormHelper::getOptionsList(); \Drupal\Core\Datetime\TimeZoneFormHelper::getOptionsListByRegion(); \Drupal\Core\Datetime\TimeZoneFormHelper::getOptionsList(NULL); \Drupal\Core\Datetime\TimeZoneFormHelper::getOptionsList(TRUE); -CODE_AFTER - , +CODE_AFTER, [ new DrupalIntroducedVersionConfiguration('10.1.0'), ] diff --git a/src/Drupal10/Rector/Deprecation/VersionedFunctionToServiceRector.php b/src/Drupal10/Rector/Deprecation/VersionedFunctionToServiceRector.php index 4b166826..b49464d0 100644 --- a/src/Drupal10/Rector/Deprecation/VersionedFunctionToServiceRector.php +++ b/src/Drupal10/Rector/Deprecation/VersionedFunctionToServiceRector.php @@ -69,12 +69,10 @@ public function getRuleDefinition(): RuleDefinition new ConfiguredCodeSample( <<<'CODE_BEFORE' _drupal_flush_css_js(); -CODE_BEFORE - , +CODE_BEFORE, <<<'CODE_AFTER' \Drupal::service('asset.query_string')->reset(); -CODE_AFTER - , +CODE_AFTER, [ new VersionedFunctionToServiceConfiguration('10.2.0', '_drupal_flush_css_js', 'asset.query_string', 'reset'), ] diff --git a/src/Drupal10/Rector/Deprecation/WatchdogExceptionRector.php b/src/Drupal10/Rector/Deprecation/WatchdogExceptionRector.php index 4c5b3531..7e60ecf9 100644 --- a/src/Drupal10/Rector/Deprecation/WatchdogExceptionRector.php +++ b/src/Drupal10/Rector/Deprecation/WatchdogExceptionRector.php @@ -78,14 +78,12 @@ public function getRuleDefinition(): RuleDefinition new ConfiguredCodeSample( <<<'CODE_BEFORE' watchdog_exception('update', $exception); -CODE_BEFORE - , +CODE_BEFORE, <<<'CODE_AFTER' use \Drupal\Core\Utility\Error; $logger = \Drupal::logger('update'); Error::logException($logger, $exception); -CODE_AFTER - , +CODE_AFTER, [ new DrupalIntroducedVersionConfiguration('10.1.0'), ] diff --git a/src/Drupal8/Rector/Deprecation/DBRector.php b/src/Drupal8/Rector/Deprecation/DBRector.php index d4c6df70..bc6ea1a1 100644 --- a/src/Drupal8/Rector/Deprecation/DBRector.php +++ b/src/Drupal8/Rector/Deprecation/DBRector.php @@ -244,12 +244,10 @@ public function getRuleDefinition(): RuleDefinition new ConfiguredCodeSample( <<<'CODE_BEFORE' db_delete($table, $options); -CODE_BEFORE - , +CODE_BEFORE, <<<'CODE_AFTER' \Drupal::database()->delete($table, $options); -CODE_AFTER - , +CODE_AFTER, [ new DBConfiguration('db_delete', 2), ] @@ -257,12 +255,10 @@ public function getRuleDefinition(): RuleDefinition new ConfiguredCodeSample( <<<'CODE_BEFORE' db_insert($table, $options); -CODE_BEFORE - , +CODE_BEFORE, <<<'CODE_AFTER' \Drupal::database()->insert($table, $options); -CODE_AFTER - , +CODE_AFTER, [ new DBConfiguration('db_insert', 2), ] @@ -270,12 +266,10 @@ public function getRuleDefinition(): RuleDefinition new ConfiguredCodeSample( <<<'CODE_BEFORE' db_query($query, $args, $options); -CODE_BEFORE - , +CODE_BEFORE, <<<'CODE_AFTER' \Drupal::database()->query($query, $args, $options); -CODE_AFTER - , +CODE_AFTER, [ new DBConfiguration('db_query', 3), ] @@ -283,12 +277,10 @@ public function getRuleDefinition(): RuleDefinition new ConfiguredCodeSample( <<<'CODE_BEFORE' db_select($table, $alias, $options); -CODE_BEFORE - , +CODE_BEFORE, <<<'CODE_AFTER' \Drupal::database()->select($table, $alias, $options); -CODE_AFTER - , +CODE_AFTER, [ new DBConfiguration('db_select', 3), ] @@ -296,12 +288,10 @@ public function getRuleDefinition(): RuleDefinition new ConfiguredCodeSample( <<<'CODE_BEFORE' db_update($table, $options); -CODE_BEFORE - , +CODE_BEFORE, <<<'CODE_AFTER' \Drupal::database()->update($table, $options); -CODE_AFTER - , +CODE_AFTER, [ new DBConfiguration('db_update', 2), ] diff --git a/src/Drupal8/Rector/Deprecation/DrupalLRector.php b/src/Drupal8/Rector/Deprecation/DrupalLRector.php index 16b84240..d150ae28 100644 --- a/src/Drupal8/Rector/Deprecation/DrupalLRector.php +++ b/src/Drupal8/Rector/Deprecation/DrupalLRector.php @@ -31,8 +31,7 @@ public function getRuleDefinition(): RuleDefinition new CodeSample( <<<'CODE_BEFORE' \Drupal::l('User Login', \Drupal\Core\Url::fromRoute('user.login')); -CODE_BEFORE - , +CODE_BEFORE, <<<'CODE_AFTER' \Drupal\Core\Link::fromTextAndUrl('User Login', \Drupal\Core\Url::fromRoute('user.login')); CODE_AFTER diff --git a/src/Drupal8/Rector/Deprecation/DrupalServiceRenameRector.php b/src/Drupal8/Rector/Deprecation/DrupalServiceRenameRector.php index 61b17330..4e2a8705 100644 --- a/src/Drupal8/Rector/Deprecation/DrupalServiceRenameRector.php +++ b/src/Drupal8/Rector/Deprecation/DrupalServiceRenameRector.php @@ -64,12 +64,10 @@ public function getRuleDefinition(): RuleDefinition new ConfiguredCodeSample( <<<'CODE_BEFORE' \Drupal::service('old')->foo(); -CODE_BEFORE - , +CODE_BEFORE, <<<'CODE_AFTER' \Drupal::service('bar')->foo(); -CODE_AFTER - , +CODE_AFTER, [ new DrupalServiceRenameConfiguration( 'old', diff --git a/src/Drupal8/Rector/Deprecation/DrupalSetMessageRector.php b/src/Drupal8/Rector/Deprecation/DrupalSetMessageRector.php index caf66587..9f2560e9 100644 --- a/src/Drupal8/Rector/Deprecation/DrupalSetMessageRector.php +++ b/src/Drupal8/Rector/Deprecation/DrupalSetMessageRector.php @@ -54,8 +54,7 @@ public function getRuleDefinition(): RuleDefinition new CodeSample( <<<'CODE_BEFORE' drupal_set_message('example status', 'status'); -CODE_BEFORE - , +CODE_BEFORE, <<<'CODE_AFTER' \Drupal::messenger()->addStatus('example status'); CODE_AFTER diff --git a/src/Drupal8/Rector/Deprecation/DrupalURLRector.php b/src/Drupal8/Rector/Deprecation/DrupalURLRector.php index 59c799f1..7ae484aa 100644 --- a/src/Drupal8/Rector/Deprecation/DrupalURLRector.php +++ b/src/Drupal8/Rector/Deprecation/DrupalURLRector.php @@ -41,8 +41,7 @@ public function getRuleDefinition(): RuleDefinition new CodeSample( <<<'CODE_BEFORE' \Drupal::url('user.login'); -CODE_BEFORE - , +CODE_BEFORE, <<<'CODE_AFTER' \Drupal\Core\Url::fromRoute('user.login')->toString(); CODE_AFTER diff --git a/src/Drupal8/Rector/Deprecation/EntityCreateRector.php b/src/Drupal8/Rector/Deprecation/EntityCreateRector.php index 8570c6f9..9f11f444 100644 --- a/src/Drupal8/Rector/Deprecation/EntityCreateRector.php +++ b/src/Drupal8/Rector/Deprecation/EntityCreateRector.php @@ -32,8 +32,7 @@ public function getRuleDefinition(): RuleDefinition new CodeSample( <<<'CODE_BEFORE' entity_create('node', ['bundle' => 'page', 'title' => 'Hello world']); -CODE_BEFORE - , +CODE_BEFORE, <<<'CODE_AFTER' \Drupal::service('entity_type.manager)->getStorage('node')->create(['bundle' => 'page', 'title' => 'Hello world']); CODE_AFTER diff --git a/src/Drupal8/Rector/Deprecation/EntityDeleteMultipleRector.php b/src/Drupal8/Rector/Deprecation/EntityDeleteMultipleRector.php index 18cbf65b..f4a75741 100644 --- a/src/Drupal8/Rector/Deprecation/EntityDeleteMultipleRector.php +++ b/src/Drupal8/Rector/Deprecation/EntityDeleteMultipleRector.php @@ -32,8 +32,7 @@ public function getRuleDefinition(): RuleDefinition new CodeSample( <<<'CODE_BEFORE' entity_delete_multiple('node', [1, 2, 42]); -CODE_BEFORE - , +CODE_BEFORE, <<<'CODE_AFTER' \Drupal::service('entity_type.manager')->getStorage('node')->delete(\Drupal::service('entity_type.manager')->getStorage('node')->loadMultiple(1, 2, 42)); CODE_AFTER diff --git a/src/Drupal8/Rector/Deprecation/EntityInterfaceLinkRector.php b/src/Drupal8/Rector/Deprecation/EntityInterfaceLinkRector.php index 9ffc0274..78ca41d9 100644 --- a/src/Drupal8/Rector/Deprecation/EntityInterfaceLinkRector.php +++ b/src/Drupal8/Rector/Deprecation/EntityInterfaceLinkRector.php @@ -42,8 +42,7 @@ public function getRuleDefinition(): RuleDefinition new CodeSample( <<<'CODE_BEFORE' $url = $entity->link(); -CODE_BEFORE - , +CODE_BEFORE, <<<'CODE_AFTER' $url = $entity->toLink()->toString(); CODE_AFTER diff --git a/src/Drupal8/Rector/Deprecation/EntityLoadRector.php b/src/Drupal8/Rector/Deprecation/EntityLoadRector.php index 66b5e5b5..a88c6a8e 100644 --- a/src/Drupal8/Rector/Deprecation/EntityLoadRector.php +++ b/src/Drupal8/Rector/Deprecation/EntityLoadRector.php @@ -51,13 +51,11 @@ public function getRuleDefinition(): RuleDefinition <<<'CODE_BEFORE' $entity = ENTITY_TYPE_load(123); $node = entity_load('node', 123); -CODE_BEFORE - , +CODE_BEFORE, <<<'CODE_AFTER' $entity = \Drupal::entityManager()->getStorage('ENTITY_TYPE')->load(123); $node = \Drupal::entityManager()->getStorage('node')->load(123); -CODE_AFTER - , +CODE_AFTER, [ new EntityLoadConfiguration('entity'), new EntityLoadConfiguration('file'), diff --git a/src/Drupal8/Rector/Deprecation/EntityManagerRector.php b/src/Drupal8/Rector/Deprecation/EntityManagerRector.php index 4bbb78c5..f0bf795d 100644 --- a/src/Drupal8/Rector/Deprecation/EntityManagerRector.php +++ b/src/Drupal8/Rector/Deprecation/EntityManagerRector.php @@ -61,8 +61,7 @@ public function getRuleDefinition(): RuleDefinition new CodeSample( <<<'CODE_BEFORE' $entity_manager = \Drupal::entityManager(); -CODE_BEFORE - , +CODE_BEFORE, <<<'CODE_AFTER' $entity_manager = \Drupal::entityTypeManager(); CODE_AFTER @@ -134,12 +133,12 @@ public function refactor(Node $node): ?Node * * @see DrupalRector\Rector\Deprecation\Base\DBBase * - * @phpstan-param class-string $class - * * @param Node\Expr\Assign $assign * @param string $class * @param string $name * + * @phpstan-param class-string $class + * * @return Node|null */ public function findInstanceByNameInAssign(Node\Expr\Assign $assign, string $class, string $name): ?Node diff --git a/src/Drupal8/Rector/Deprecation/EntityViewRector.php b/src/Drupal8/Rector/Deprecation/EntityViewRector.php index 26e035b1..c0e161f8 100644 --- a/src/Drupal8/Rector/Deprecation/EntityViewRector.php +++ b/src/Drupal8/Rector/Deprecation/EntityViewRector.php @@ -42,8 +42,7 @@ public function getRuleDefinition(): RuleDefinition new CodeSample( <<<'CODE_BEFORE' $rendered = entity_view($entity, 'default'); -CODE_BEFORE - , +CODE_BEFORE, <<<'CODE_AFTER' $rendered = \Drupal::entityTypeManager()->getViewBuilder($entity ->getEntityTypeId())->view($entity, 'default'); diff --git a/src/Drupal8/Rector/Deprecation/FileDefaultSchemeRector.php b/src/Drupal8/Rector/Deprecation/FileDefaultSchemeRector.php index 2d98cd86..ca3d7e5c 100644 --- a/src/Drupal8/Rector/Deprecation/FileDefaultSchemeRector.php +++ b/src/Drupal8/Rector/Deprecation/FileDefaultSchemeRector.php @@ -62,8 +62,7 @@ public function getRuleDefinition(): RuleDefinition new CodeSample( <<<'CODE_BEFORE' $file_default_scheme = file_default_scheme(); -CODE_BEFORE - , +CODE_BEFORE, <<<'CODE_AFTER' $file_default_scheme = \Drupal::config('system.file')->get('default_scheme'); CODE_AFTER diff --git a/src/Drupal8/Rector/Deprecation/FunctionalTestDefaultThemePropertyRector.php b/src/Drupal8/Rector/Deprecation/FunctionalTestDefaultThemePropertyRector.php index 2168b796..242da332 100644 --- a/src/Drupal8/Rector/Deprecation/FunctionalTestDefaultThemePropertyRector.php +++ b/src/Drupal8/Rector/Deprecation/FunctionalTestDefaultThemePropertyRector.php @@ -48,9 +48,7 @@ public function getRuleDefinition(): RuleDefinition <<<'CODE_SAMPLE' class SomeClassTest { } -CODE_SAMPLE - - , +CODE_SAMPLE, <<<'CODE_SAMPLE' class SomeClassTest { protected $defaultTheme = 'stark' diff --git a/src/Drupal8/Rector/Deprecation/GetMockRector.php b/src/Drupal8/Rector/Deprecation/GetMockRector.php index 2f9f673d..de89627b 100644 --- a/src/Drupal8/Rector/Deprecation/GetMockRector.php +++ b/src/Drupal8/Rector/Deprecation/GetMockRector.php @@ -106,12 +106,10 @@ public function getRuleDefinition(): RuleDefinition new ConfiguredCodeSample( <<<'CODE_BEFORE' $this->entityTypeManager = $this->getMock(EntityTypeManagerInterface::class); -CODE_BEFORE - , +CODE_BEFORE, <<<'CODE_AFTER' $this->entityTypeManager = $this->createMock(EntityTypeManagerInterface::class); -CODE_AFTER - , +CODE_AFTER, [ new GetMockConfiguration('Drupal\Tests\BrowserTestBase'), new GetMockConfiguration('Drupal\KernelTests\KernelTestBase'), diff --git a/src/Drupal8/Rector/Deprecation/LinkGeneratorTraitLRector.php b/src/Drupal8/Rector/Deprecation/LinkGeneratorTraitLRector.php index 4195de5c..a6900714 100644 --- a/src/Drupal8/Rector/Deprecation/LinkGeneratorTraitLRector.php +++ b/src/Drupal8/Rector/Deprecation/LinkGeneratorTraitLRector.php @@ -46,8 +46,7 @@ public function getRuleDefinition(): RuleDefinition new CodeSample( <<<'CODE_BEFORE' $this->l($text, $url); -CODE_BEFORE - , +CODE_BEFORE, <<<'CODE_AFTER' \Drupal\Core\Link::fromTextAndUrl($text, $url); CODE_AFTER diff --git a/src/Drupal8/Rector/Deprecation/RequestTimeConstRector.php b/src/Drupal8/Rector/Deprecation/RequestTimeConstRector.php index 526f61b8..faf01e44 100644 --- a/src/Drupal8/Rector/Deprecation/RequestTimeConstRector.php +++ b/src/Drupal8/Rector/Deprecation/RequestTimeConstRector.php @@ -49,8 +49,7 @@ public function getRuleDefinition(): RuleDefinition new CodeSample( <<<'CODE_BEFORE' $request_time = REQUEST_TIME; -CODE_BEFORE - , +CODE_BEFORE, <<<'CODE_AFTER' $request_time = \Drupal::time()->getRequestTime(); CODE_AFTER diff --git a/src/Drupal8/Rector/Deprecation/SafeMarkupFormatRector.php b/src/Drupal8/Rector/Deprecation/SafeMarkupFormatRector.php index 74059525..7662fb99 100644 --- a/src/Drupal8/Rector/Deprecation/SafeMarkupFormatRector.php +++ b/src/Drupal8/Rector/Deprecation/SafeMarkupFormatRector.php @@ -30,8 +30,7 @@ public function getRuleDefinition(): RuleDefinition new CodeSample( <<<'CODE_BEFORE' $safe_string_markup_object = \Drupal\Component\Utility\SafeMarkup::format('hello world'); -CODE_BEFORE - , +CODE_BEFORE, <<<'CODE_AFTER' $safe_string_markup_object = new \Drupal\Component\Render\FormattableMarkup('hello world'); CODE_AFTER diff --git a/src/Drupal8/Rector/Deprecation/StaticToFunctionRector.php b/src/Drupal8/Rector/Deprecation/StaticToFunctionRector.php index 59ab837e..a9618df2 100644 --- a/src/Drupal8/Rector/Deprecation/StaticToFunctionRector.php +++ b/src/Drupal8/Rector/Deprecation/StaticToFunctionRector.php @@ -68,12 +68,10 @@ public function getRuleDefinition(): RuleDefinition new ConfiguredCodeSample( <<<'CODE_BEFORE' $length = \Drupal\Component\Utility\Unicode::strlen('example'); -CODE_BEFORE - , +CODE_BEFORE, <<<'CODE_AFTER' $length = mb_strlen('example'); -CODE_AFTER - , +CODE_AFTER, [ new StaticToFunctionConfiguration('Drupal\Component\Utility\Unicode', 'strlen', 'mb_strlen'), ] @@ -81,12 +79,10 @@ public function getRuleDefinition(): RuleDefinition new ConfiguredCodeSample( <<<'CODE_BEFORE' $string = \Drupal\Component\Utility\Unicode::strtolower('example'); -CODE_BEFORE - , +CODE_BEFORE, <<<'CODE_AFTER' $string = mb_strtolower('example'); -CODE_AFTER - , +CODE_AFTER, [ new StaticToFunctionConfiguration('Drupal\Component\Utility\Unicode', 'strtolower', 'mb_strtolower'), ] @@ -94,12 +90,10 @@ public function getRuleDefinition(): RuleDefinition new ConfiguredCodeSample( <<<'CODE_BEFORE' $string = \Drupal\Component\Utility\Unicode::substr('example', 0, 2); -CODE_BEFORE - , +CODE_BEFORE, <<<'CODE_AFTER' $string = mb_substr('example', 0, 2); -CODE_AFTER - , +CODE_AFTER, [ new StaticToFunctionConfiguration('Drupal\Component\Utility\Unicode', 'substr', 'mb_substr'), ] diff --git a/src/Drupal9/Rector/Deprecation/AssertFieldByIdRector.php b/src/Drupal9/Rector/Deprecation/AssertFieldByIdRector.php index c5132e22..ce7c03ce 100644 --- a/src/Drupal9/Rector/Deprecation/AssertFieldByIdRector.php +++ b/src/Drupal9/Rector/Deprecation/AssertFieldByIdRector.php @@ -21,8 +21,7 @@ public function getRuleDefinition(): RuleDefinition $this->assertFieldById('edit-name', 'Test name'); $this->assertFieldById('edit-description', NULL); $this->assertFieldById('edit-description'); -CODE_BEFORE - , +CODE_BEFORE, <<<'CODE_AFTER' $this->assertSession()->fieldExists('edit-name'); $this->assertSession()->fieldValueEquals('edit-name', 'Test name'); diff --git a/src/Drupal9/Rector/Deprecation/AssertFieldByNameRector.php b/src/Drupal9/Rector/Deprecation/AssertFieldByNameRector.php index 68666dae..4f4749a1 100644 --- a/src/Drupal9/Rector/Deprecation/AssertFieldByNameRector.php +++ b/src/Drupal9/Rector/Deprecation/AssertFieldByNameRector.php @@ -19,8 +19,7 @@ public function getRuleDefinition(): RuleDefinition $this->assertFieldByName('field_name', 'expected_value'); $this->assertFieldByName("field_name[0][value][date]", '', 'Date element found.'); $this->assertFieldByName("field_name[0][value][time]", null, 'Time element found.'); -CODE_BEFORE - , +CODE_BEFORE, <<<'CODE_AFTER' $this->assertSession()->fieldValueEquals('field_name', 'expected_value'); $this->assertSession()->fieldValueEquals("field_name[0][value][date]", ''); diff --git a/src/Drupal9/Rector/Deprecation/AssertLegacyTraitRector.php b/src/Drupal9/Rector/Deprecation/AssertLegacyTraitRector.php index ad86c765..7af6fe10 100644 --- a/src/Drupal9/Rector/Deprecation/AssertLegacyTraitRector.php +++ b/src/Drupal9/Rector/Deprecation/AssertLegacyTraitRector.php @@ -122,12 +122,10 @@ public function getRuleDefinition(): RuleDefinition new ConfiguredCodeSample( <<<'CODE_BEFORE' $this->assertLinkByHref('user/1/translations'); -CODE_BEFORE - , +CODE_BEFORE, <<<'CODE_AFTER' $this->assertSession()->linkByHrefExists('user/1/translations'); -CODE_AFTER - , +CODE_AFTER, [ new AssertLegacyTraitConfiguration('assertLinkByHref', 'linkByHrefExists'), ] @@ -135,12 +133,10 @@ public function getRuleDefinition(): RuleDefinition new ConfiguredCodeSample( <<<'CODE_BEFORE' $this->assertLink('Anonymous comment title'); -CODE_BEFORE - , +CODE_BEFORE, <<<'CODE_AFTER' $this->assertSession()->linkExists('Anonymous comment title'); -CODE_AFTER - , +CODE_AFTER, [ new AssertLegacyTraitConfiguration('assertLink', 'linkExists'), ] @@ -148,12 +144,10 @@ public function getRuleDefinition(): RuleDefinition new ConfiguredCodeSample( <<<'CODE_BEFORE' $this->assertNoEscaped('
'); -CODE_BEFORE - , +CODE_BEFORE, <<<'CODE_AFTER' $this->assertSession()->assertNoEscaped('
'); -CODE_AFTER - , +CODE_AFTER, [ new AssertLegacyTraitConfiguration('assertNoEscaped', 'assertNoEscaped'), ] @@ -161,12 +155,10 @@ public function getRuleDefinition(): RuleDefinition new ConfiguredCodeSample( <<<'CODE_BEFORE' $this->assertNoFieldChecked('edit-settings-view-mode', 'default'); -CODE_BEFORE - , +CODE_BEFORE, <<<'CODE_AFTER' $this->assertSession()->checkboxNotChecked('edit-settings-view-mode', 'default'); -CODE_AFTER - , +CODE_AFTER, [ new AssertLegacyTraitConfiguration('assertNoFieldChecked', 'checkboxNotChecked'), ] @@ -174,12 +166,10 @@ public function getRuleDefinition(): RuleDefinition new ConfiguredCodeSample( <<<'CODE_BEFORE' $this->assertNoField('files[upload]', 'Found file upload field.'); -CODE_BEFORE - , +CODE_BEFORE, <<<'CODE_AFTER' $this->assertSession()->fieldNotExists('files[upload]', 'Found file upload field.'); -CODE_AFTER - , +CODE_AFTER, [ new AssertLegacyTraitConfiguration('assertNoField', 'fieldNotExists', 'Change assertion to buttonExists() if checking for a button.'), ] @@ -187,12 +177,10 @@ public function getRuleDefinition(): RuleDefinition new ConfiguredCodeSample( <<<'CODE_BEFORE' $this->assertNoLinkByHref('user/2/translations'); -CODE_BEFORE - , +CODE_BEFORE, <<<'CODE_AFTER' $this->assertSession()->linkByHrefNotExists('user/2/translations'); -CODE_AFTER - , +CODE_AFTER, [ new AssertLegacyTraitConfiguration('assertNoLinkByHref', 'linkByHrefNotExists'), ] @@ -200,12 +188,10 @@ public function getRuleDefinition(): RuleDefinition new ConfiguredCodeSample( <<<'CODE_BEFORE' $this->assertNoLink('Anonymous comment title'); -CODE_BEFORE - , +CODE_BEFORE, <<<'CODE_AFTER' $this->assertSession()->linkNotExists('Anonymous comment title'); -CODE_AFTER - , +CODE_AFTER, [ new AssertLegacyTraitConfiguration('assertNoLink', 'linkNotExists'), ] @@ -213,12 +199,10 @@ public function getRuleDefinition(): RuleDefinition new ConfiguredCodeSample( <<<'CODE_BEFORE' $this->assertNoOption('edit-settings-view-mode', 'default'); -CODE_BEFORE - , +CODE_BEFORE, <<<'CODE_AFTER' $this->assertSession()->optionNotExists('edit-settings-view-mode', 'default'); -CODE_AFTER - , +CODE_AFTER, [ new AssertLegacyTraitConfiguration('assertNoOption', 'optionNotExists'), ] @@ -226,12 +210,10 @@ public function getRuleDefinition(): RuleDefinition new ConfiguredCodeSample( <<<'CODE_BEFORE' $this->assertNoPattern('|]*>|', 'No empty H4 element found.'); -CODE_BEFORE - , +CODE_BEFORE, <<<'CODE_AFTER' $this->assertSession()->responseNotMatches('|]*>|', 'No empty H4 element found.'); -CODE_AFTER - , +CODE_AFTER, [ new AssertLegacyTraitConfiguration('assertNoPattern', 'responseNotMatches'), ] @@ -239,12 +221,10 @@ public function getRuleDefinition(): RuleDefinition new ConfiguredCodeSample( <<<'CODE_BEFORE' $this->assertPattern('|]*>|', 'No empty H4 element found.'); -CODE_BEFORE - , +CODE_BEFORE, <<<'CODE_AFTER' $this->assertSession()->responseMatches('|]*>|', 'No empty H4 element found.'); -CODE_AFTER - , +CODE_AFTER, [ new AssertLegacyTraitConfiguration('assertPattern', 'responseMatches'), ] @@ -252,12 +232,10 @@ public function getRuleDefinition(): RuleDefinition new ConfiguredCodeSample( <<<'CODE_BEFORE' $this->assertNoRaw('bartik/logo.svg'); -CODE_BEFORE - , +CODE_BEFORE, <<<'CODE_AFTER' $this->assertSession()->responseNotContains('bartik/logo.svg'); -CODE_AFTER - , +CODE_AFTER, [ new AssertLegacyTraitConfiguration('assertNoRaw', 'responseNotContains', '', true, true), ] @@ -265,12 +243,10 @@ public function getRuleDefinition(): RuleDefinition new ConfiguredCodeSample( <<<'CODE_BEFORE' $this->assertRaw('bartik/logo.svg'); -CODE_BEFORE - , +CODE_BEFORE, <<<'CODE_AFTER' $this->assertSession()->responseContains('bartik/logo.svg'); -CODE_AFTER - , +CODE_AFTER, [ new AssertLegacyTraitConfiguration('assertRaw', 'responseNotContains', '', true, true), ] diff --git a/src/Drupal9/Rector/Deprecation/AssertNoFieldByIdRector.php b/src/Drupal9/Rector/Deprecation/AssertNoFieldByIdRector.php index 7d4d313a..c6cc4622 100644 --- a/src/Drupal9/Rector/Deprecation/AssertNoFieldByIdRector.php +++ b/src/Drupal9/Rector/Deprecation/AssertNoFieldByIdRector.php @@ -19,8 +19,7 @@ public function getRuleDefinition(): RuleDefinition $this->assertNoFieldById('name'); $this->assertNoFieldById('name', 'not the value'); $this->assertNoFieldById('notexisting', NULL); -CODE_BEFORE - , +CODE_BEFORE, <<<'CODE_AFTER' $this->assertSession()->assertNoFieldById('name'); $this->assertSession()->fieldValueNotEquals('name', 'not the value'); diff --git a/src/Drupal9/Rector/Deprecation/AssertNoFieldByNameRector.php b/src/Drupal9/Rector/Deprecation/AssertNoFieldByNameRector.php index 5ffd8f69..d49f74b2 100644 --- a/src/Drupal9/Rector/Deprecation/AssertNoFieldByNameRector.php +++ b/src/Drupal9/Rector/Deprecation/AssertNoFieldByNameRector.php @@ -40,8 +40,7 @@ public function getRuleDefinition(): RuleDefinition $this->assertNoFieldByName('name', 'not the value'); $this->assertNoFieldByName('notexisting'); $this->assertNoFieldByName('notexisting', NULL); -CODE_BEFORE - , +CODE_BEFORE, <<<'CODE_AFTER' $this->assertSession()->fieldValueNotEquals('name', ''); $this->assertSession()->fieldValueNotEquals('name', 'not the value'); diff --git a/src/Drupal9/Rector/Deprecation/AssertNoUniqueTextRector.php b/src/Drupal9/Rector/Deprecation/AssertNoUniqueTextRector.php index 588b1785..07402567 100644 --- a/src/Drupal9/Rector/Deprecation/AssertNoUniqueTextRector.php +++ b/src/Drupal9/Rector/Deprecation/AssertNoUniqueTextRector.php @@ -21,8 +21,7 @@ public function getRuleDefinition(): RuleDefinition new CodeSample( <<<'CODE_BEFORE' $this->assertNoUniqueText('Duplicated message'); -CODE_BEFORE - , +CODE_BEFORE, <<<'CODE_AFTER' $page_text = $this->getSession()->getPage()->getText(); $nr_found = substr_count($page_text, 'Duplicated message'); diff --git a/src/Drupal9/Rector/Deprecation/AssertOptionSelectedRector.php b/src/Drupal9/Rector/Deprecation/AssertOptionSelectedRector.php index 09b7ae71..554a4855 100644 --- a/src/Drupal9/Rector/Deprecation/AssertOptionSelectedRector.php +++ b/src/Drupal9/Rector/Deprecation/AssertOptionSelectedRector.php @@ -17,8 +17,7 @@ public function getRuleDefinition(): RuleDefinition new CodeSample( <<<'CODE_BEFORE' $this->assertOptionSelected('options', 2); -CODE_BEFORE - , +CODE_BEFORE, <<<'CODE_AFTER' $this->assertTrue($this->assertSession()->optionExists('options', 2)->hasAttribute('selected')); CODE_AFTER diff --git a/src/Drupal9/Rector/Deprecation/ConstructFieldXpathRector.php b/src/Drupal9/Rector/Deprecation/ConstructFieldXpathRector.php index f6c9b14e..84e26137 100644 --- a/src/Drupal9/Rector/Deprecation/ConstructFieldXpathRector.php +++ b/src/Drupal9/Rector/Deprecation/ConstructFieldXpathRector.php @@ -20,8 +20,7 @@ public function getRuleDefinition(): RuleDefinition new CodeSample( <<<'CODE_BEFORE' $this->constructFieldXpath('id', 'edit-preferred-admin-langcode'); -CODE_BEFORE - , +CODE_BEFORE, <<<'CODE_AFTER' $this->getSession()->getPage()->findField('edit-preferred-admin-langcode'); CODE_AFTER diff --git a/src/Drupal9/Rector/Deprecation/ExtensionPathRector.php b/src/Drupal9/Rector/Deprecation/ExtensionPathRector.php index a8043d94..1cc6e2bd 100644 --- a/src/Drupal9/Rector/Deprecation/ExtensionPathRector.php +++ b/src/Drupal9/Rector/Deprecation/ExtensionPathRector.php @@ -135,14 +135,12 @@ public function getRuleDefinition(): RuleDefinition drupal_get_filename('module', 'node'); drupal_get_filename('theme', 'seven'); drupal_get_filename('profile', 'standard'); -CODE_BEFORE - , +CODE_BEFORE, <<<'CODE_AFTER' \Drupal::service('extension.list.module')->getPathname('node'); \Drupal::service('extension.list.theme')->getPathname('seven'); \Drupal::service('extension.list.profile')->getPathname('standard'); -CODE_AFTER - , +CODE_AFTER, [ new ExtensionPathConfiguration('drupal_get_filename', 'getPathname'), ] @@ -152,14 +150,12 @@ public function getRuleDefinition(): RuleDefinition drupal_get_path('module', 'node'); drupal_get_path('theme', 'seven'); drupal_get_path('profile', 'standard'); -CODE_BEFORE - , +CODE_BEFORE, <<<'CODE_AFTER' \Drupal::service('extension.list.module')->getPath('node'); \Drupal::service('extension.list.theme')->getPath('seven'); \Drupal::service('extension.list.profile')->getPath('standard'); -CODE_AFTER - , +CODE_AFTER, [ new ExtensionPathConfiguration('drupal_get_path', 'getPath'), ] diff --git a/src/Drupal9/Rector/Deprecation/FileBuildUriRector.php b/src/Drupal9/Rector/Deprecation/FileBuildUriRector.php index 8ebefe34..42388966 100644 --- a/src/Drupal9/Rector/Deprecation/FileBuildUriRector.php +++ b/src/Drupal9/Rector/Deprecation/FileBuildUriRector.php @@ -22,8 +22,7 @@ public function getRuleDefinition(): RuleDefinition $uri1 = file_build_uri('path/to/file.txt'); $path = 'path/to/other/file.png'; $uri2 = file_build_uri($path); -CODE_BEFORE - , +CODE_BEFORE, <<<'CODE_AFTER' $uri1 = \Drupal::service('stream_wrapper_manager')->normalizeUri(\Drupal::config('system.file')->get('default_scheme') . ('://' . 'path/to/file.txt')); $path = 'path/to/other/file.png'; diff --git a/src/Drupal9/Rector/Deprecation/FileCreateUrlRector.php b/src/Drupal9/Rector/Deprecation/FileCreateUrlRector.php index 1054a6d1..a4400f19 100644 --- a/src/Drupal9/Rector/Deprecation/FileCreateUrlRector.php +++ b/src/Drupal9/Rector/Deprecation/FileCreateUrlRector.php @@ -17,8 +17,7 @@ public function getRuleDefinition(): RuleDefinition new CodeSample( <<<'CODE_BEFORE' file_create_url($uri); -CODE_BEFORE - , +CODE_BEFORE, <<<'CODE_AFTER' \Drupal::service('file_url_generator')->generateAbsoluteString($uri); CODE_AFTER diff --git a/src/Drupal9/Rector/Deprecation/FileUrlTransformRelativeRector.php b/src/Drupal9/Rector/Deprecation/FileUrlTransformRelativeRector.php index 1fa90220..091d21f4 100644 --- a/src/Drupal9/Rector/Deprecation/FileUrlTransformRelativeRector.php +++ b/src/Drupal9/Rector/Deprecation/FileUrlTransformRelativeRector.php @@ -17,8 +17,7 @@ public function getRuleDefinition(): RuleDefinition new CodeSample( <<<'CODE_BEFORE' file_url_transform_relative($uri); -CODE_BEFORE - , +CODE_BEFORE, <<<'CODE_AFTER' \Drupal::service('file_url_generator')->transformRelative($uri); CODE_AFTER diff --git a/src/Drupal9/Rector/Deprecation/FromUriRector.php b/src/Drupal9/Rector/Deprecation/FromUriRector.php index f88f83e7..6424299b 100644 --- a/src/Drupal9/Rector/Deprecation/FromUriRector.php +++ b/src/Drupal9/Rector/Deprecation/FromUriRector.php @@ -21,8 +21,7 @@ public function getRuleDefinition(): RuleDefinition new CodeSample( <<<'CODE_BEFORE' \Drupal\Core\Url::fromUri(file_create_url($uri)); -CODE_BEFORE - , +CODE_BEFORE, <<<'CODE_AFTER' \Drupal::service('file_url_generator')->generate($uri); CODE_AFTER diff --git a/src/Drupal9/Rector/Deprecation/FunctionToEntityTypeStorageMethod.php b/src/Drupal9/Rector/Deprecation/FunctionToEntityTypeStorageMethod.php index 74c02230..ee117f35 100644 --- a/src/Drupal9/Rector/Deprecation/FunctionToEntityTypeStorageMethod.php +++ b/src/Drupal9/Rector/Deprecation/FunctionToEntityTypeStorageMethod.php @@ -41,14 +41,12 @@ public function getRuleDefinition(): RuleDefinition taxonomy_terms_static_reset(); taxonomy_vocabulary_static_reset($vids); - CODE_BEFORE - , + CODE_BEFORE, <<<'CODE_AFTER' \Drupal::entityTypeManager()->getStorage('taxonomy_term')->resetCache(); \Drupal::entityTypeManager()->getStorage('taxonomy_vocabulary')->resetCache($vids); - CODE_AFTER - , + CODE_AFTER, [ new FunctionToEntityTypeStorageConfiguration('taxonomy_terms_static_reset', 'taxonomy_term', 'resetCache'), new FunctionToEntityTypeStorageConfiguration('taxonomy_vocabulary_static_reset', 'taxonomy_vocabulary', 'resetCache'), diff --git a/src/Drupal9/Rector/Deprecation/FunctionToFirstArgMethodRector.php b/src/Drupal9/Rector/Deprecation/FunctionToFirstArgMethodRector.php index 7a89089e..82721096 100644 --- a/src/Drupal9/Rector/Deprecation/FunctionToFirstArgMethodRector.php +++ b/src/Drupal9/Rector/Deprecation/FunctionToFirstArgMethodRector.php @@ -71,13 +71,11 @@ public function getRuleDefinition(): RuleDefinition <<<'CODE_BEFORE' $url = taxonomy_term_uri($term); $name = taxonomy_term_title($term); -CODE_BEFORE - , +CODE_BEFORE, <<<'CODE_AFTER' $url = $term->toUrl(); $name = $term->label(); -CODE_AFTER - , +CODE_AFTER, [ new FunctionToFirstArgMethodConfiguration('taxonomy_term_uri', 'toUrl'), new FunctionToFirstArgMethodConfiguration('taxonomy_term_title', 'label'), diff --git a/src/Drupal9/Rector/Deprecation/GetAllOptionsRector.php b/src/Drupal9/Rector/Deprecation/GetAllOptionsRector.php index 68a57c69..880943c8 100644 --- a/src/Drupal9/Rector/Deprecation/GetAllOptionsRector.php +++ b/src/Drupal9/Rector/Deprecation/GetAllOptionsRector.php @@ -32,8 +32,7 @@ public function getRuleDefinition(): RuleDefinition <<<'CODE_BEFORE' $this->drupalGet('/form-test/select'); $this->assertCount(6, $this->getAllOptions($this->cssSelect('select[name="opt_groups"]')[0])); -CODE_BEFORE - , +CODE_BEFORE, <<<'CODE_AFTER' $this->drupalGet('/form-test/select'); $this->assertCount(6, $this->cssSelect('select[name="opt_groups"]')[0]->findAll('xpath', '//option')); diff --git a/src/Drupal9/Rector/Deprecation/GetRawContentRector.php b/src/Drupal9/Rector/Deprecation/GetRawContentRector.php index cf6d9dcb..0b900406 100644 --- a/src/Drupal9/Rector/Deprecation/GetRawContentRector.php +++ b/src/Drupal9/Rector/Deprecation/GetRawContentRector.php @@ -31,8 +31,7 @@ public function getRuleDefinition(): RuleDefinition new CodeSample( <<<'CODE_BEFORE' $this->getRawContent(); -CODE_BEFORE - , +CODE_BEFORE, <<<'CODE_AFTER' $this->getSession()->getPage()->getContent(); CODE_AFTER diff --git a/src/Drupal9/Rector/Deprecation/ModuleLoadRector.php b/src/Drupal9/Rector/Deprecation/ModuleLoadRector.php index 37c38d55..d2aac31c 100644 --- a/src/Drupal9/Rector/Deprecation/ModuleLoadRector.php +++ b/src/Drupal9/Rector/Deprecation/ModuleLoadRector.php @@ -57,8 +57,7 @@ public function getRuleDefinition(): RuleDefinition $name = 'name'; module_load_include($type, $module, $name); module_load_include($type, $module); -CODE_BEFORE - , +CODE_BEFORE, <<<'CODE_AFTER' \Drupal::moduleHandler()->loadInclude('example', 'install'); $type = 'install'; diff --git a/src/Drupal9/Rector/Deprecation/PassRector.php b/src/Drupal9/Rector/Deprecation/PassRector.php index b06368d7..b286a3f3 100644 --- a/src/Drupal9/Rector/Deprecation/PassRector.php +++ b/src/Drupal9/Rector/Deprecation/PassRector.php @@ -23,8 +23,7 @@ public function getRuleDefinition(): RuleDefinition <<<'CODE_BEFORE' // Check for pass $this->pass('The whole transaction is rolled back when a duplicate key insert occurs.'); -CODE_BEFORE - , +CODE_BEFORE, <<<'CODE_AFTER' // Check for pass CODE_AFTER diff --git a/src/Drupal9/Rector/Deprecation/SystemSortByInfoNameRector.php b/src/Drupal9/Rector/Deprecation/SystemSortByInfoNameRector.php index b99f44e4..6b549a9c 100644 --- a/src/Drupal9/Rector/Deprecation/SystemSortByInfoNameRector.php +++ b/src/Drupal9/Rector/Deprecation/SystemSortByInfoNameRector.php @@ -47,8 +47,7 @@ public function getRuleDefinition(): RuleDefinition new CodeSample( <<<'CODE_BEFORE' uasort($modules, 'system_sort_modules_by_info_name'); -CODE_BEFORE - , +CODE_BEFORE, <<<'CODE_AFTER' uasort($modules, [ModuleExtensionList::class, 'sortByName']); CODE_AFTER diff --git a/src/Drupal9/Rector/Deprecation/TaxonomyTermLoadMultipleByNameRector.php b/src/Drupal9/Rector/Deprecation/TaxonomyTermLoadMultipleByNameRector.php index 37be4883..c5142d92 100644 --- a/src/Drupal9/Rector/Deprecation/TaxonomyTermLoadMultipleByNameRector.php +++ b/src/Drupal9/Rector/Deprecation/TaxonomyTermLoadMultipleByNameRector.php @@ -21,8 +21,7 @@ public function getRuleDefinition(): RuleDefinition 'Foo', 'topics' ); - CODE_BEFORE - , + CODE_BEFORE, <<<'CODE_AFTER' $terms = \Drupal::entityTypeManager()->getStorage('taxonomy_term')->loadByProperties([ 'name' => 'Foo', diff --git a/src/Drupal9/Rector/Deprecation/TaxonomyVocabularyGetNamesDrupalStaticResetRector.php b/src/Drupal9/Rector/Deprecation/TaxonomyVocabularyGetNamesDrupalStaticResetRector.php index 85843ad4..77f6e9af 100644 --- a/src/Drupal9/Rector/Deprecation/TaxonomyVocabularyGetNamesDrupalStaticResetRector.php +++ b/src/Drupal9/Rector/Deprecation/TaxonomyVocabularyGetNamesDrupalStaticResetRector.php @@ -18,8 +18,7 @@ public function getRuleDefinition(): RuleDefinition new CodeSample( <<<'CODE_BEFORE' drupal_static_reset('taxonomy_vocabulary_get_names'); - CODE_BEFORE - , + CODE_BEFORE, <<<'CODE_AFTER' \Drupal::entityTypeManager()->getStorage('taxonomy_vocabulary')->resetCache(); CODE_AFTER diff --git a/src/Drupal9/Rector/Deprecation/TaxonomyVocabularyGetNamesRector.php b/src/Drupal9/Rector/Deprecation/TaxonomyVocabularyGetNamesRector.php index d19ba3f1..398b561e 100644 --- a/src/Drupal9/Rector/Deprecation/TaxonomyVocabularyGetNamesRector.php +++ b/src/Drupal9/Rector/Deprecation/TaxonomyVocabularyGetNamesRector.php @@ -18,8 +18,7 @@ public function getRuleDefinition(): RuleDefinition new CodeSample( <<<'CODE_BEFORE' $vids = taxonomy_vocabulary_get_names(); - CODE_BEFORE - , + CODE_BEFORE, <<<'CODE_AFTER' $vids = \Drupal::entityQuery('taxonomy_vocabulary')->execute(); CODE_AFTER diff --git a/src/Drupal9/Rector/Deprecation/UiHelperTraitDrupalPostFormRector.php b/src/Drupal9/Rector/Deprecation/UiHelperTraitDrupalPostFormRector.php index a531bcfa..67599908 100644 --- a/src/Drupal9/Rector/Deprecation/UiHelperTraitDrupalPostFormRector.php +++ b/src/Drupal9/Rector/Deprecation/UiHelperTraitDrupalPostFormRector.php @@ -22,8 +22,7 @@ public function getRuleDefinition(): RuleDefinition $this->drupalPostForm('admin/config/system/actions', $edit, 'Create'); $edit['action'] = 'action_goto_action_1'; $this->drupalPostForm(null, $edit, 'Edit'); -CODE_BEFORE - , +CODE_BEFORE, <<<'CODE_AFTER' $edit = []; $edit['action'] = 'action_goto_action'; diff --git a/src/Drupal9/Rector/Deprecation/UserPasswordRector.php b/src/Drupal9/Rector/Deprecation/UserPasswordRector.php index e6c10d26..80ce7098 100644 --- a/src/Drupal9/Rector/Deprecation/UserPasswordRector.php +++ b/src/Drupal9/Rector/Deprecation/UserPasswordRector.php @@ -21,8 +21,7 @@ public function getRuleDefinition(): RuleDefinition <<<'CODE_BEFORE' $pass = user_password(); $shorter_pass = user_password(8); -CODE_BEFORE - , +CODE_BEFORE, <<<'CODE_AFTER' $pass = \Drupal::service('password_generator')->generate(); $shorter_pass = \Drupal::service('password_generator')->generate(8); diff --git a/src/Drupal9/Rector/Property/ProtectedStaticModulesPropertyRector.php b/src/Drupal9/Rector/Property/ProtectedStaticModulesPropertyRector.php index 7b8116f2..b86c8ace 100644 --- a/src/Drupal9/Rector/Property/ProtectedStaticModulesPropertyRector.php +++ b/src/Drupal9/Rector/Property/ProtectedStaticModulesPropertyRector.php @@ -30,9 +30,7 @@ public function getRuleDefinition(): RuleDefinition class SomeClassTest { public static $modules = []; } -CODE_SAMPLE - - , +CODE_SAMPLE, <<<'CODE_SAMPLE' class SomeClassTest { protected static $modules = []; diff --git a/src/Rector/Convert/HookConvertRector.php b/src/Rector/Convert/HookConvertRector.php index d36bb55f..00f977cf 100644 --- a/src/Rector/Convert/HookConvertRector.php +++ b/src/Rector/Convert/HookConvertRector.php @@ -86,8 +86,7 @@ function hookconvertrector_user_cancel($edit, UserInterface $account, $method) { 'blue' => 'blue', ]; } -CODE_SAMPLE - , +CODE_SAMPLE, <<<'CODE_SAMPLE' /** * Hook implementations for hookconvertrector. @@ -241,17 +240,17 @@ protected function createMethodFromFunction(Function_ $node): ?ClassMethod if ($info = $this->getHookAndModuleName($node)) { ['hook' => $hook, 'module' => $implementsModule] = $info; $procOnly = [ - 'hook_info', - 'install', - 'install_tasks', - 'install_tasks_alter', - 'module_implements_alter', - 'removed_post_updates', - 'requirements', - 'schema', - 'uninstall', - 'update_dependencies', - 'update_last_removed', + 'hook_info', + 'install', + 'install_tasks', + 'install_tasks_alter', + 'module_implements_alter', + 'removed_post_updates', + 'requirements', + 'schema', + 'uninstall', + 'update_dependencies', + 'update_last_removed', ]; if (in_array($hook, $procOnly)) { return null; diff --git a/src/Rector/Deprecation/ClassConstantToClassConstantRector.php b/src/Rector/Deprecation/ClassConstantToClassConstantRector.php index de78184c..336494b0 100644 --- a/src/Rector/Deprecation/ClassConstantToClassConstantRector.php +++ b/src/Rector/Deprecation/ClassConstantToClassConstantRector.php @@ -47,14 +47,12 @@ public function getRuleDefinition(): RuleDefinition $value = Symfony\Cmf\Component\Routing\RouteObjectInterface::ROUTE_NAME; $value2 = Symfony\Cmf\Component\Routing\RouteObjectInterface::ROUTE_OBJECT; $value3 = Symfony\Cmf\Component\Routing\RouteObjectInterface::CONTROLLER_NAME; -CODE_BEFORE - , +CODE_BEFORE, <<<'CODE_AFTER' $value = \Drupal\Core\Routing\RouteObjectInterface::ROUTE_NAME; $value2 = \Drupal\Core\Routing\RouteObjectInterface::ROUTE_OBJECT; $value3 = \Drupal\Core\Routing\RouteObjectInterface::CONTROLLER_NAME; -CODE_AFTER - , +CODE_AFTER, [ new ClassConstantToClassConstantConfiguration( 'Symfony\Cmf\Component\Routing\RouteObjectInterface', diff --git a/src/Rector/Deprecation/ConstantToClassConstantRector.php b/src/Rector/Deprecation/ConstantToClassConstantRector.php index cb1cc7ae..63e359fd 100644 --- a/src/Rector/Deprecation/ConstantToClassConstantRector.php +++ b/src/Rector/Deprecation/ConstantToClassConstantRector.php @@ -44,12 +44,10 @@ public function getRuleDefinition(): RuleDefinition new ConfiguredCodeSample( <<<'CODE_BEFORE' $result = file_unmanaged_copy($source, $destination, DEPRECATED_CONSTANT); -CODE_BEFORE - , +CODE_BEFORE, <<<'CODE_AFTER' $result = file_unmanaged_copy($source, $destination, \Drupal\MyClass::CONSTANT); -CODE_AFTER - , +CODE_AFTER, [ new ConstantToClassConfiguration( 'DEPRECATED_CONSTANT', diff --git a/src/Rector/Deprecation/DeprecationHelperRemoveRector.php b/src/Rector/Deprecation/DeprecationHelperRemoveRector.php index 634c6857..c5553bcb 100644 --- a/src/Rector/Deprecation/DeprecationHelperRemoveRector.php +++ b/src/Rector/Deprecation/DeprecationHelperRemoveRector.php @@ -31,15 +31,13 @@ public function getRuleDefinition(): RuleDefinition DeprecationHelper::backwardsCompatibleCall(\Drupal::VERSION, '9.1.0', fn() => new_function(), fn() => old_function()); DeprecationHelper::backwardsCompatibleCall(\Drupal::VERSION, '10.5.0', fn() => SettingsEditor::rewrite($filename, $settings), fn() => drupal_rewrite_settings($settings, $filename)); DeprecationHelper::backwardsCompatibleCall(\Drupal::VERSION, '11.1.0', fn() => new_function(), fn() => old_function()); -CODE_BEFORE - , +CODE_BEFORE, <<<'CODE_AFTER' $settings = []; $filename = 'simple_filename.yaml'; drupal_rewrite_settings($settings, $filename); DeprecationHelper::backwardsCompatibleCall(\Drupal::VERSION, '11.1.0', fn() => new_function(), fn() => old_function()); -CODE_AFTER - , +CODE_AFTER, [ new DeprecationHelperRemoveConfiguration('10.5.0'), ] diff --git a/src/Rector/Deprecation/FunctionToServiceRector.php b/src/Rector/Deprecation/FunctionToServiceRector.php index 26b5a7ef..9b8275eb 100644 --- a/src/Rector/Deprecation/FunctionToServiceRector.php +++ b/src/Rector/Deprecation/FunctionToServiceRector.php @@ -74,13 +74,11 @@ public function getRuleDefinition(): RuleDefinition new ConfiguredCodeSample( <<<'CODE_BEFORE' $path = drupal_realpath($path); -CODE_BEFORE - , +CODE_BEFORE, <<<'CODE_AFTER' $path = \Drupal::service('file_system') ->realpath($path); -CODE_AFTER - , +CODE_AFTER, [ new FunctionToServiceConfiguration('8.0.0', 'drupal_realpath', 'file_system', 'realpath'), ] @@ -88,12 +86,10 @@ public function getRuleDefinition(): RuleDefinition new ConfiguredCodeSample( <<<'CODE_BEFORE' $result = drupal_render($elements); -CODE_BEFORE - , +CODE_BEFORE, <<<'CODE_AFTER' $result = \Drupal::service('renderer')->render($elements); -CODE_AFTER - , +CODE_AFTER, [ new FunctionToServiceConfiguration('8.0.0', 'drupal_render', 'renderer', 'render'), ] @@ -101,12 +97,10 @@ public function getRuleDefinition(): RuleDefinition new ConfiguredCodeSample( <<<'CODE_BEFORE' $result = drupal_render_root($elements); -CODE_BEFORE - , +CODE_BEFORE, <<<'CODE_AFTER' $result = \Drupal::service('renderer')->renderRoot($elements); -CODE_AFTER - , +CODE_AFTER, [ new FunctionToServiceConfiguration('8.0.0', 'drupal_render_root', 'renderer', 'renderRoot'), ] @@ -114,13 +108,11 @@ public function getRuleDefinition(): RuleDefinition new ConfiguredCodeSample( <<<'CODE_BEFORE' $display = entity_get_display($entity_type, $bundle, $view_mode) -CODE_BEFORE - , +CODE_BEFORE, <<<'CODE_AFTER' $display = \Drupal::service('entity_display.repository') ->getViewDisplay($entity_type, $bundle, $view_mode); -CODE_AFTER - , +CODE_AFTER, [ new FunctionToServiceConfiguration('8.8.0', 'entity_get_display', 'entity_display.repository', 'getViewDisplay'), ] @@ -128,13 +120,11 @@ public function getRuleDefinition(): RuleDefinition new ConfiguredCodeSample( <<<'CODE_BEFORE' $display = entity_get_form_display($entity_type, $bundle, $form_mode) -CODE_BEFORE - , +CODE_BEFORE, <<<'CODE_AFTER' $display = \Drupal::service('entity_display.repository') ->getFormDisplay($entity_type, $bundle, $form_mode); -CODE_AFTER - , +CODE_AFTER, [ new FunctionToServiceConfiguration('8.8.0', 'entity_get_form_display', 'entity_display.repository', 'getFormDisplay'), ] @@ -142,12 +132,10 @@ public function getRuleDefinition(): RuleDefinition new ConfiguredCodeSample( <<<'CODE_BEFORE' file_copy(); -CODE_BEFORE - , +CODE_BEFORE, <<<'CODE_AFTER' \Drupal::service('file.repository')->copy(); -CODE_AFTER - , +CODE_AFTER, [ new FunctionToServiceConfiguration('9.3.0', 'file_copy', 'file.repository', 'copy'), ] @@ -155,12 +143,10 @@ public function getRuleDefinition(): RuleDefinition new ConfiguredCodeSample( <<<'CODE_BEFORE' $dir = file_directory_temp(); -CODE_BEFORE - , +CODE_BEFORE, <<<'CODE_AFTER' $dir = \Drupal::service('file_system')->getTempDirectory(); -CODE_AFTER - , +CODE_AFTER, [ new FunctionToServiceConfiguration('8.0.0', 'file_directory_temp', 'file_system', 'getTempDirectory'), ] @@ -168,12 +154,10 @@ public function getRuleDefinition(): RuleDefinition new ConfiguredCodeSample( <<<'CODE_BEFORE' file_move(); -CODE_BEFORE - , +CODE_BEFORE, <<<'CODE_AFTER' \Drupal::service('file.repository')->move(); -CODE_AFTER - , +CODE_AFTER, [ new FunctionToServiceConfiguration('9.3.0', 'file_move', 'file.repository', 'move'), ] @@ -181,12 +165,10 @@ public function getRuleDefinition(): RuleDefinition new ConfiguredCodeSample( <<<'CODE_BEFORE' $result = file_prepare_directory($directory, $options); -CODE_BEFORE - , +CODE_BEFORE, <<<'CODE_AFTER' $result = \Drupal::service('file_system')->prepareDirectory($directory, $options); -CODE_AFTER - , +CODE_AFTER, [ new FunctionToServiceConfiguration('8.7.0', 'file_prepare_directory', 'file_system', 'prepareDirectory'), ] @@ -194,12 +176,10 @@ public function getRuleDefinition(): RuleDefinition new ConfiguredCodeSample( <<<'CODE_BEFORE' file_save_data($data); -CODE_BEFORE - , +CODE_BEFORE, <<<'CODE_AFTER' \Drupal::service('file.repository')->writeData($data); -CODE_AFTER - , +CODE_AFTER, [ new FunctionToServiceConfiguration('8.7.0', 'file_save_data', 'file.repository', 'writeData'), ] @@ -207,12 +187,10 @@ public function getRuleDefinition(): RuleDefinition new ConfiguredCodeSample( <<<'CODE_BEFORE' $files = file_scan_directory($directory); -CODE_BEFORE - , +CODE_BEFORE, <<<'CODE_AFTER' $files = \Drupal::service('file_system')->scanDirectory($directory); -CODE_AFTER - , +CODE_AFTER, [ new FunctionToServiceConfiguration('8.8.0', 'file_scan_directory', 'file_system', 'scanDirectory'), ] @@ -220,12 +198,10 @@ public function getRuleDefinition(): RuleDefinition new ConfiguredCodeSample( <<<'CODE_BEFORE' $result = file_unmanaged_save_data($data, $destination, $replace); -CODE_BEFORE - , +CODE_BEFORE, <<<'CODE_AFTER' $result = \Drupal::service('file_system')->saveData($data, $destination, $replace); -CODE_AFTER - , +CODE_AFTER, [ new FunctionToServiceConfiguration('9.3.0', 'file_unmanaged_save_data', 'file_system', 'saveData'), ] @@ -233,12 +209,10 @@ public function getRuleDefinition(): RuleDefinition new ConfiguredCodeSample( <<<'CODE_BEFORE' $result = file_uri_target($uri) -CODE_BEFORE - , +CODE_BEFORE, <<<'CODE_AFTER' $result = \Drupal::service('stream_wrapper_manager')->getTarget($uri); -CODE_AFTER - , +CODE_AFTER, [ new FunctionToServiceConfiguration('8.8.0', 'file_uri_target', 'stream_wrapper_manager', 'getTarget'), ] @@ -246,12 +220,10 @@ public function getRuleDefinition(): RuleDefinition new ConfiguredCodeSample( <<<'CODE_BEFORE' $date = format_date($timestamp, $type, $format, $timezone, $langcode); -CODE_BEFORE - , +CODE_BEFORE, <<<'CODE_AFTER' $date = \Drupal::service('date.formatter')->format($timestamp, $type, $format, $timezone, $langcode); -CODE_AFTER - , +CODE_AFTER, [ new FunctionToServiceConfiguration('8.0.0', 'format_date', 'date.formatter', 'format'), ] @@ -259,12 +231,10 @@ public function getRuleDefinition(): RuleDefinition new ConfiguredCodeSample( <<<'CODE_BEFORE' $date = format_date($timestamp, $type, $format, $timezone, $langcode); -CODE_BEFORE - , +CODE_BEFORE, <<<'CODE_AFTER' $date = \Drupal::service('date.formatter')->format($timestamp, $type, $format, $timezone, $langcode); -CODE_AFTER - , +CODE_AFTER, [ new FunctionToServiceConfiguration('8.0.0', 'format_date', 'date.formatter', 'format'), ] @@ -272,12 +242,10 @@ public function getRuleDefinition(): RuleDefinition new ConfiguredCodeSample( <<<'CODE_BEFORE' $output = render($build); -CODE_BEFORE - , +CODE_BEFORE, <<<'CODE_AFTER' $output = \Drupal::service('renderer')->render($build); -CODE_AFTER - , +CODE_AFTER, [ new FunctionToServiceConfiguration('9.3.0', 'render', 'renderer', 'render'), ] diff --git a/src/Rector/Deprecation/FunctionToStaticRector.php b/src/Rector/Deprecation/FunctionToStaticRector.php index f4db0499..808e2033 100644 --- a/src/Rector/Deprecation/FunctionToStaticRector.php +++ b/src/Rector/Deprecation/FunctionToStaticRector.php @@ -78,12 +78,10 @@ public function getRuleDefinition(): RuleDefinition new ConfiguredCodeSample( <<<'CODE_BEFORE' $dir = file_directory_os_temp(); -CODE_BEFORE - , +CODE_BEFORE, <<<'CODE_AFTER' $dir = \Drupal\Component\FileSystem\FileSystem::getOsTemporaryDirectory(); -CODE_AFTER - , +CODE_AFTER, [ new FunctionToStaticConfiguration('8.1.0', 'file_directory_os_temp', 'Drupal\Component\FileSystem\FileSystem', 'getOsTemporaryDirectory'), ] @@ -93,14 +91,12 @@ public function getRuleDefinition(): RuleDefinition $settings = []; $filename = 'simple_filename.yaml'; drupal_rewrite_settings($settings, $filename); -CODE_BEFORE - , +CODE_BEFORE, <<<'CODE_AFTER' $settings = []; $filename = 'simple_filename.yaml'; SettingsEditor::rewrite($filename, $settings); -CODE_AFTER - , +CODE_AFTER, [ new FunctionToStaticConfiguration('10.1.0', 'drupal_rewrite_settings', 'Drupal\Core\Site\SettingsEditor', 'rewrite', [0 => 1, 1 => 0]), ] @@ -110,14 +106,12 @@ public function getRuleDefinition(): RuleDefinition $settings = []; $filename = 'simple_filename.yaml'; drupal_rewrite_settings($settings, $filename); -CODE_BEFORE - , +CODE_BEFORE, <<<'CODE_AFTER' $settings = []; $filename = 'simple_filename.yaml'; SettingsEditor::rewrite($filename, $settings); -CODE_AFTER - , +CODE_AFTER, [ new FunctionToStaticConfiguration('10.1.0', 'drupal_rewrite_settings', 'Drupal\Core\Site\SettingsEditor', 'rewrite', [0 => 1, 1 => 0]), ] diff --git a/src/Rector/Deprecation/MethodToMethodWithCheckRector.php b/src/Rector/Deprecation/MethodToMethodWithCheckRector.php index 9ab91198..1f0f173e 100644 --- a/src/Rector/Deprecation/MethodToMethodWithCheckRector.php +++ b/src/Rector/Deprecation/MethodToMethodWithCheckRector.php @@ -160,13 +160,11 @@ public function getRuleDefinition(): RuleDefinition <<<'CODE_BEFORE' $metadata_bag = new \Drupal\Core\Session\MetadataBag(new \Drupal\Core\Site\Settings([])); $metadata_bag->clearCsrfTokenSeed(); -CODE_BEFORE - , +CODE_BEFORE, <<<'CODE_AFTER' $metadata_bag = new \Drupal\Core\Session\MetadataBag(new \Drupal\Core\Site\Settings([])); $metadata_bag->stampNew(); -CODE_AFTER - , +CODE_AFTER, [ new MethodToMethodWithCheckConfiguration( 'Drupal\Core\Session\MetadataBag', @@ -178,12 +176,10 @@ public function getRuleDefinition(): RuleDefinition new ConfiguredCodeSample( <<<'CODE_BEFORE' $url = $entity->urlInfo(); -CODE_BEFORE - , +CODE_BEFORE, <<<'CODE_AFTER' $url = $entity->toUrl(); -CODE_AFTER - , +CODE_AFTER, [ new MethodToMethodWithCheckConfiguration('Drupal\Core\Entity\EntityInterface', 'urlInfo', 'toUrl'), ] @@ -194,15 +190,13 @@ public function getRuleDefinition(): RuleDefinition $node = \Drupal::entityTypeManager()->getStorage('node')->load(123); $entity_type = $node->getEntityType(); $entity_type->getLowercaseLabel(); -CODE_BEFORE - , +CODE_BEFORE, <<<'CODE_AFTER' /* @var \Drupal\node\Entity\Node $node */ $node = \Drupal::entityTypeManager()->getStorage('node')->load(123); $entity_type = $node->getEntityType(); $entity_type->getSingularLabel(); -CODE_AFTER - , +CODE_AFTER, [ new MethodToMethodWithCheckConfiguration('Drupal\Core\Entity\EntityTypeInterface', 'getLowercaseLabel', 'getSingularLabel'), ] diff --git a/src/Rector/PHPUnit/ShouldCallParentMethodsRector.php b/src/Rector/PHPUnit/ShouldCallParentMethodsRector.php index e133f6a3..b0228798 100644 --- a/src/Rector/PHPUnit/ShouldCallParentMethodsRector.php +++ b/src/Rector/PHPUnit/ShouldCallParentMethodsRector.php @@ -20,10 +20,10 @@ public function getNodeTypes(): array } /** - * @phpstan-param Node\Stmt\ClassMethod $node - * * @param Node $node * + * @phpstan-param Node\Stmt\ClassMethod $node + * * @return Node|null */ public function refactor(Node $node) @@ -134,8 +134,7 @@ protected function tearDown(): void } } -CODE_BEFORE - , +CODE_BEFORE, <<<'CODE_SAMPLE' namespace Drupal\Tests\Rector\Deprecation\PHPUnit\ShouldCallParentMethodsRector\fixture;