From ff33b93c134a98ab8d25f5bf64acd779cb87d536 Mon Sep 17 00:00:00 2001 From: bjorn Date: Sun, 17 Dec 2023 21:32:27 +0100 Subject: [PATCH 01/18] Add support for module_load_include into existing module_load_install rector. --- config/drupal-9/drupal-9.4-deprecations.php | 2 +- ...InstallRector.php => ModuleLoadRector.php} | 20 ++++++++- .../fixture/basic.php.inc | 25 ----------- .../ModuleLoadRectorTest.php} | 4 +- .../config/configured_rule.php | 4 +- .../ModuleLoadRector/fixture/basic.php.inc | 43 +++++++++++++++++++ 6 files changed, 66 insertions(+), 32 deletions(-) rename src/Drupal9/Rector/Deprecation/{ModuleLoadInstallRector.php => ModuleLoadRector.php} (64%) delete mode 100644 tests/src/Drupal9/Rector/Deprecation/ModuleLoadInstallRector/fixture/basic.php.inc rename tests/src/Drupal9/Rector/Deprecation/{ModuleLoadInstallRector/ModuleLoadInstallRectorTest.php => ModuleLoadRector/ModuleLoadRectorTest.php} (82%) rename tests/src/Drupal9/Rector/Deprecation/{ModuleLoadInstallRector => ModuleLoadRector}/config/configured_rule.php (54%) create mode 100644 tests/src/Drupal9/Rector/Deprecation/ModuleLoadRector/fixture/basic.php.inc diff --git a/config/drupal-9/drupal-9.4-deprecations.php b/config/drupal-9/drupal-9.4-deprecations.php index 16d66f83..8c5ab1c2 100644 --- a/config/drupal-9/drupal-9.4-deprecations.php +++ b/config/drupal-9/drupal-9.4-deprecations.php @@ -4,5 +4,5 @@ return static function (Rector\Config\RectorConfig $rectorConfig): void { // Change record https://www.drupal.org/node/3220952 - $rectorConfig->rule(\DrupalRector\Drupal9\Rector\Deprecation\ModuleLoadInstallRector::class); + $rectorConfig->rule(\DrupalRector\Drupal9\Rector\Deprecation\ModuleLoadRector::class); }; diff --git a/src/Drupal9/Rector/Deprecation/ModuleLoadInstallRector.php b/src/Drupal9/Rector/Deprecation/ModuleLoadRector.php similarity index 64% rename from src/Drupal9/Rector/Deprecation/ModuleLoadInstallRector.php rename to src/Drupal9/Rector/Deprecation/ModuleLoadRector.php index bffa01d9..866623ae 100644 --- a/src/Drupal9/Rector/Deprecation/ModuleLoadInstallRector.php +++ b/src/Drupal9/Rector/Deprecation/ModuleLoadRector.php @@ -12,7 +12,7 @@ /** * Replaces deprecated module_load_install call with ModuleHandler call. */ -class ModuleLoadInstallRector extends AbstractRector +class ModuleLoadRector extends AbstractRector { /** * {@inheritdoc} @@ -35,6 +35,12 @@ public function refactor(Node $node): ?Node\Expr\CallLike $args[] = new Node\Arg(new Node\Scalar\String_('install')); return $this->nodeFactory->createMethodCall($this->nodeFactory->createStaticCall('Drupal', 'moduleHandler'), 'loadInclude', $args); + } elseif ($this->getName($node->name) === 'module_load_include') { + $newArgs = $args = $node->getArgs(); + $newArgs[0] = $args[1]; + $newArgs[1] = $args[0]; + + return $this->nodeFactory->createMethodCall($this->nodeFactory->createStaticCall('Drupal', 'moduleHandler'), 'loadInclude', $newArgs); } return null; @@ -46,10 +52,20 @@ public function getRuleDefinition(): RuleDefinition new CodeSample( <<<'CODE_BEFORE' module_load_install('example'); +$type = 'install'; +$module = 'example'; +$name = 'name'; +module_load_include($type, $module, $name); +module_load_include($type, $module); CODE_BEFORE , <<<'CODE_AFTER' -\Drupal\Core\Extension\ModuleHandler::loadInclude('example', 'install'); +\Drupal::moduleHandler()->loadInclude('example', 'install'); +$type = 'install'; +$module = 'example'; +$name = 'name'; +\Drupal::moduleHandler()->loadInclude($module, $type, $name); +\Drupal::moduleHandler()->loadInclude($module, $type); CODE_AFTER ), ]); diff --git a/tests/src/Drupal9/Rector/Deprecation/ModuleLoadInstallRector/fixture/basic.php.inc b/tests/src/Drupal9/Rector/Deprecation/ModuleLoadInstallRector/fixture/basic.php.inc deleted file mode 100644 index 7857c2fc..00000000 --- a/tests/src/Drupal9/Rector/Deprecation/ModuleLoadInstallRector/fixture/basic.php.inc +++ /dev/null @@ -1,25 +0,0 @@ - ------ -loadInclude('example', 'install'); - - $module = 'simple'; - \Drupal::moduleHandler()->loadInclude($module, 'install'); -} -?> diff --git a/tests/src/Drupal9/Rector/Deprecation/ModuleLoadInstallRector/ModuleLoadInstallRectorTest.php b/tests/src/Drupal9/Rector/Deprecation/ModuleLoadRector/ModuleLoadRectorTest.php similarity index 82% rename from tests/src/Drupal9/Rector/Deprecation/ModuleLoadInstallRector/ModuleLoadInstallRectorTest.php rename to tests/src/Drupal9/Rector/Deprecation/ModuleLoadRector/ModuleLoadRectorTest.php index 37e36032..cebd2d9c 100644 --- a/tests/src/Drupal9/Rector/Deprecation/ModuleLoadInstallRector/ModuleLoadInstallRectorTest.php +++ b/tests/src/Drupal9/Rector/Deprecation/ModuleLoadRector/ModuleLoadRectorTest.php @@ -2,12 +2,12 @@ declare(strict_types=1); -namespace Drupal9\Rector\Deprecation\ModuleLoadInstallRector; +namespace Drupal9\Rector\Deprecation\ModuleLoadRector; use Iterator; use Rector\Testing\PHPUnit\AbstractRectorTestCase; -class ModuleLoadInstallRectorTest extends AbstractRectorTestCase +class ModuleLoadRectorTest extends AbstractRectorTestCase { /** * @covers ::refactor diff --git a/tests/src/Drupal9/Rector/Deprecation/ModuleLoadInstallRector/config/configured_rule.php b/tests/src/Drupal9/Rector/Deprecation/ModuleLoadRector/config/configured_rule.php similarity index 54% rename from tests/src/Drupal9/Rector/Deprecation/ModuleLoadInstallRector/config/configured_rule.php rename to tests/src/Drupal9/Rector/Deprecation/ModuleLoadRector/config/configured_rule.php index eab586ad..f9b9c03a 100644 --- a/tests/src/Drupal9/Rector/Deprecation/ModuleLoadInstallRector/config/configured_rule.php +++ b/tests/src/Drupal9/Rector/Deprecation/ModuleLoadRector/config/configured_rule.php @@ -2,10 +2,10 @@ declare(strict_types=1); -use DrupalRector\Drupal9\Rector\Deprecation\ModuleLoadInstallRector; +use DrupalRector\Drupal9\Rector\Deprecation\ModuleLoadRector; use DrupalRector\Tests\Rector\Deprecation\DeprecationBase; use Rector\Config\RectorConfig; return static function (RectorConfig $rectorConfig): void { - DeprecationBase::addClass(ModuleLoadInstallRector::class, $rectorConfig, false); + DeprecationBase::addClass(ModuleLoadRector::class, $rectorConfig, false); }; diff --git a/tests/src/Drupal9/Rector/Deprecation/ModuleLoadRector/fixture/basic.php.inc b/tests/src/Drupal9/Rector/Deprecation/ModuleLoadRector/fixture/basic.php.inc new file mode 100644 index 00000000..11609627 --- /dev/null +++ b/tests/src/Drupal9/Rector/Deprecation/ModuleLoadRector/fixture/basic.php.inc @@ -0,0 +1,43 @@ + +----- +loadInclude('example', 'install'); + + $module = 'simple'; + \Drupal::moduleHandler()->loadInclude($module, 'install'); + + $type = 'install'; + $module = 'example'; + $name = 'name'; + \Drupal::moduleHandler()->loadInclude($module, $type, $name); + \Drupal::moduleHandler()->loadInclude($module, $type); + + \Drupal::moduleHandler()->loadInclude('example', 'install', 'name'); + \Drupal::moduleHandler()->loadInclude('example', 'install'); +} +?> From 8910e6d62ac2f2fc357deb00eebfe8e0b781e2d8 Mon Sep 17 00:00:00 2001 From: bjorn Date: Sun, 17 Dec 2023 21:37:10 +0100 Subject: [PATCH 02/18] update docs --- docs/rules_overview.md | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/docs/rules_overview.md b/docs/rules_overview.md index 251bb3b1..f6580895 100644 --- a/docs/rules_overview.md +++ b/docs/rules_overview.md @@ -715,15 +715,22 @@ Fixes deprecated `AssertLegacyTrait::getRawContent()` calls
-### ModuleLoadInstallRector +### ModuleLoadRector Fixes deprecated `module_load_install()` calls -- class: [`DrupalRector\Drupal9\Rector\Deprecation\ModuleLoadInstallRector`](../src/Drupal9/Rector/Deprecation/ModuleLoadInstallRector.php) +- class: [`DrupalRector\Drupal9\Rector\Deprecation\ModuleLoadRector`](../src/Drupal9/Rector/Deprecation/ModuleLoadRector.php) ```diff -module_load_install('example'); -+\Drupal\Core\Extension\ModuleHandler::loadInclude('example', 'install'); ++\Drupal::moduleHandler()->loadInclude('example', 'install'); + $type = 'install'; + $module = 'example'; + $name = 'name'; +-module_load_include($type, $module, $name); +-module_load_include($type, $module); ++\Drupal::moduleHandler()->loadInclude($module, $type, $name); ++\Drupal::moduleHandler()->loadInclude($module, $type); ```
From 4210d56b91d23a8d3885b3f9aed9d360c4444c3c Mon Sep 17 00:00:00 2001 From: bjorn Date: Sat, 23 Dec 2023 11:17:03 +0100 Subject: [PATCH 03/18] New rector (9.3): Support FILE_STATUS_PERMANENT deprecation - https://www.drupal.org/node/3022147 --- config/drupal-9/drupal-9.3-deprecations.php | 8 ++++++++ .../config/configured_rule.php | 7 +++++++ .../ConstantToClassConstantRector/fixture/fixture.php.inc | 8 ++++++++ 3 files changed, 23 insertions(+) diff --git a/config/drupal-9/drupal-9.3-deprecations.php b/config/drupal-9/drupal-9.3-deprecations.php index 5289e421..45ee406b 100644 --- a/config/drupal-9/drupal-9.3-deprecations.php +++ b/config/drupal-9/drupal-9.3-deprecations.php @@ -2,6 +2,7 @@ declare(strict_types=1); +use DrupalRector\Drupal8\Rector\ValueObject\ConstantToClassConfiguration; use DrupalRector\Drupal9\Rector\Deprecation\ExtensionPathRector; use DrupalRector\Drupal9\Rector\Deprecation\FileBuildUriRector; use DrupalRector\Drupal9\Rector\Deprecation\FunctionToEntityTypeStorageMethod; @@ -66,4 +67,11 @@ new FunctionToFirstArgMethodConfiguration('taxonomy_term_uri', 'toUrl'), new FunctionToFirstArgMethodConfiguration('taxonomy_term_title', 'label'), ]); + + // Change record: https://www.drupal.org/node/3022147 + new ConstantToClassConfiguration( + 'FILE_STATUS_PERMANENT', + 'Drupal\file\FileInterface', + 'STATUS_PERMANENT', + ); }; diff --git a/tests/src/Drupal8/Rector/Deprecation/ConstantToClassConstantRector/config/configured_rule.php b/tests/src/Drupal8/Rector/Deprecation/ConstantToClassConstantRector/config/configured_rule.php index c43f965a..aeec0664 100644 --- a/tests/src/Drupal8/Rector/Deprecation/ConstantToClassConstantRector/config/configured_rule.php +++ b/tests/src/Drupal8/Rector/Deprecation/ConstantToClassConstantRector/config/configured_rule.php @@ -15,4 +15,11 @@ 'STORAGE_TIMEZONE', ), ]); + DeprecationBase::addClass(ConstantToClassConstantRector::class, $rectorConfig, false, [ + new ConstantToClassConfiguration( + 'FILE_STATUS_PERMANENT', + 'Drupal\file\FileInterface', + 'STATUS_PERMANENT', + ), + ]); }; diff --git a/tests/src/Drupal8/Rector/Deprecation/ConstantToClassConstantRector/fixture/fixture.php.inc b/tests/src/Drupal8/Rector/Deprecation/ConstantToClassConstantRector/fixture/fixture.php.inc index d10ece7c..582e3412 100644 --- a/tests/src/Drupal8/Rector/Deprecation/ConstantToClassConstantRector/fixture/fixture.php.inc +++ b/tests/src/Drupal8/Rector/Deprecation/ConstantToClassConstantRector/fixture/fixture.php.inc @@ -2,10 +2,14 @@ function simple_example() { $timezone = DATETIME_STORAGE_TIMEZONE; + + $file_status = FILE_STATUS_PERMANENT; } function as_an_argument() { $timezone = new \DateTimeZone(DATETIME_STORAGE_TIMEZONE); + + $class = new \TestClass(FILE_STATUS_PERMANENT); } ?> ----- @@ -13,9 +17,13 @@ function as_an_argument() { function simple_example() { $timezone = \Drupal\datetime\Plugin\Field\FieldType\DateTimeItemInterface::STORAGE_TIMEZONE; + + $file_status = \Drupal\file\FileInterface::STATUS_PERMANENT; } function as_an_argument() { $timezone = new \DateTimeZone(\Drupal\datetime\Plugin\Field\FieldType\DateTimeItemInterface::STORAGE_TIMEZONE); + + $class = new \TestClass(\Drupal\file\FileInterface::STATUS_PERMANENT); } ?> From c13c401a2e684ce042b557ed3996f2c39f9d1733 Mon Sep 17 00:00:00 2001 From: bjorn Date: Sat, 23 Dec 2023 11:23:06 +0100 Subject: [PATCH 04/18] Add test for class method argument as seen in codesearch in gitlab --- .../fixture/fixture.php.inc | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/tests/src/Drupal8/Rector/Deprecation/ConstantToClassConstantRector/fixture/fixture.php.inc b/tests/src/Drupal8/Rector/Deprecation/ConstantToClassConstantRector/fixture/fixture.php.inc index 582e3412..c49f064a 100644 --- a/tests/src/Drupal8/Rector/Deprecation/ConstantToClassConstantRector/fixture/fixture.php.inc +++ b/tests/src/Drupal8/Rector/Deprecation/ConstantToClassConstantRector/fixture/fixture.php.inc @@ -11,6 +11,13 @@ function as_an_argument() { $class = new \TestClass(FILE_STATUS_PERMANENT); } + +class ClassDefault { + public function test($status = FILE_STATUS_PERMANENT) { + return true; + } +} + ?> ----- From 4919535569dc4a6287039644e44223988119792e Mon Sep 17 00:00:00 2001 From: bjorn Date: Sat, 23 Dec 2023 12:18:13 +0100 Subject: [PATCH 05/18] New rector: \Drupal\Component\Utility\Bytes::toInt() is deprecated \Drupal\Component\Utility\Bytes::toInt() is deprecated in favor of \Drupal\Component\Utility\Bytes::toNumber() https://www.drupal.org/node/3162663 --- config/drupal-9/drupal-9.1-deprecations.php | 11 +++++++++++ fixtures/d9/rector_examples/rector_examples.module | 4 ++++ .../d9/rector_examples_updated/rector_examples.module | 5 +++++ 3 files changed, 20 insertions(+) diff --git a/config/drupal-9/drupal-9.1-deprecations.php b/config/drupal-9/drupal-9.1-deprecations.php index c62eee8f..fd8df5a8 100644 --- a/config/drupal-9/drupal-9.1-deprecations.php +++ b/config/drupal-9/drupal-9.1-deprecations.php @@ -18,6 +18,8 @@ use DrupalRector\Services\AddCommentService; use Rector\Config\RectorConfig; use Rector\PHPUnit\Set\PHPUnitSetList; +use Rector\Renaming\Rector\StaticCall\RenameStaticMethodRector; +use Rector\Renaming\ValueObject\RenameStaticMethod; return static function (RectorConfig $rectorConfig): void { $rectorConfig->singleton(AddCommentService::class, function () { @@ -95,4 +97,13 @@ $rectorConfig->rule(GetRawContentRector::class); $rectorConfig->rule(GetAllOptionsRector::class); $rectorConfig->rule(UserPasswordRector::class); + + $rectorConfig->ruleWithConfiguration(RenameStaticMethodRector::class, [ + new RenameStaticMethod( + 'Drupal\Component\Utility\Bytes', + 'toInt', + 'Drupal\Component\Utility\Bytes', + 'toNumber' + ), + ]); }; diff --git a/fixtures/d9/rector_examples/rector_examples.module b/fixtures/d9/rector_examples/rector_examples.module index 937e4b4f..f629deb8 100644 --- a/fixtures/d9/rector_examples/rector_examples.module +++ b/fixtures/d9/rector_examples/rector_examples.module @@ -13,3 +13,7 @@ function rector_examples_with_render() { $build = []; $output = render($build); } + +function rector_utility_bytes_to_int() { + $int = \Drupal\Component\Utility\Bytes::toInt("15"); +} diff --git a/fixtures/d9/rector_examples_updated/rector_examples.module b/fixtures/d9/rector_examples_updated/rector_examples.module index 6e116901..068e6be1 100644 --- a/fixtures/d9/rector_examples_updated/rector_examples.module +++ b/fixtures/d9/rector_examples_updated/rector_examples.module @@ -13,3 +13,8 @@ function rector_examples_with_render() { $build = []; $output = \Drupal::service('renderer')->render($build); } + +function rector_utility_bytes_to_int() { + $int = \Drupal\Component\Utility\Bytes::toNumber("15"); +} + From 781039bc4c2f44235e1067bc32a8e6a98a0e390f Mon Sep 17 00:00:00 2001 From: bjorn Date: Sat, 23 Dec 2023 12:20:22 +0100 Subject: [PATCH 06/18] Functinoal test confuse me. Namespace included. --- fixtures/d9/rector_examples/rector_examples.module | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/fixtures/d9/rector_examples/rector_examples.module b/fixtures/d9/rector_examples/rector_examples.module index f629deb8..61738d50 100644 --- a/fixtures/d9/rector_examples/rector_examples.module +++ b/fixtures/d9/rector_examples/rector_examples.module @@ -1,5 +1,6 @@ Date: Sat, 23 Dec 2023 12:22:23 +0100 Subject: [PATCH 07/18] Functinoal test confuse me. Namespace included. Also add change record reference --- config/drupal-9/drupal-9.1-deprecations.php | 1 + fixtures/d9/rector_examples_updated/rector_examples.module | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/config/drupal-9/drupal-9.1-deprecations.php b/config/drupal-9/drupal-9.1-deprecations.php index fd8df5a8..8a6d1999 100644 --- a/config/drupal-9/drupal-9.1-deprecations.php +++ b/config/drupal-9/drupal-9.1-deprecations.php @@ -98,6 +98,7 @@ $rectorConfig->rule(GetAllOptionsRector::class); $rectorConfig->rule(UserPasswordRector::class); + // Change record: https://www.drupal.org/node/3162663 $rectorConfig->ruleWithConfiguration(RenameStaticMethodRector::class, [ new RenameStaticMethod( 'Drupal\Component\Utility\Bytes', diff --git a/fixtures/d9/rector_examples_updated/rector_examples.module b/fixtures/d9/rector_examples_updated/rector_examples.module index 068e6be1..dc068537 100644 --- a/fixtures/d9/rector_examples_updated/rector_examples.module +++ b/fixtures/d9/rector_examples_updated/rector_examples.module @@ -1,5 +1,6 @@ getPath('node'); \Drupal::service('extension.list.theme')->getPath('seven'); @@ -15,6 +16,6 @@ function rector_examples_with_render() { } function rector_utility_bytes_to_int() { - $int = \Drupal\Component\Utility\Bytes::toNumber("15"); + $int = Bytes::toNumber("15"); } From 63e4282443c7ce22892a2c18b1c5af0b2ca3e3e1 Mon Sep 17 00:00:00 2001 From: bjorn Date: Thu, 28 Dec 2023 09:33:50 +0100 Subject: [PATCH 08/18] NMew rector FILE_STATUS_PERMANENT was not added to deprecation list. Only config object was intialized. --- config/drupal-9/drupal-9.3-deprecations.php | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/config/drupal-9/drupal-9.3-deprecations.php b/config/drupal-9/drupal-9.3-deprecations.php index 45ee406b..894747b8 100644 --- a/config/drupal-9/drupal-9.3-deprecations.php +++ b/config/drupal-9/drupal-9.3-deprecations.php @@ -2,6 +2,7 @@ declare(strict_types=1); +use DrupalRector\Drupal8\Rector\Deprecation\ConstantToClassConstantRector; use DrupalRector\Drupal8\Rector\ValueObject\ConstantToClassConfiguration; use DrupalRector\Drupal9\Rector\Deprecation\ExtensionPathRector; use DrupalRector\Drupal9\Rector\Deprecation\FileBuildUriRector; @@ -69,9 +70,11 @@ ]); // Change record: https://www.drupal.org/node/3022147 - new ConstantToClassConfiguration( - 'FILE_STATUS_PERMANENT', - 'Drupal\file\FileInterface', - 'STATUS_PERMANENT', - ); + $rectorConfig->ruleWithConfiguration(ConstantToClassConstantRector::class, [ + new ConstantToClassConfiguration( + 'FILE_STATUS_PERMANENT', + 'Drupal\file\FileInterface', + 'STATUS_PERMANENT', + ), + ]); }; From 8614659d9c546fd663bd129ddc5ce58c8d4ff1ea Mon Sep 17 00:00:00 2001 From: bjorn Date: Thu, 28 Dec 2023 12:08:18 +0100 Subject: [PATCH 09/18] Fix codestyle issues --- .../Rector/Deprecation/SystemTimeZonesRector.php | 2 +- src/Drupal8/Rector/Deprecation/DBRector.php | 2 +- .../Rector/Deprecation/DrupalSetMessageRector.php | 2 +- .../Rector/Deprecation/EntityInterfaceLinkRector.php | 2 +- src/Drupal8/Rector/Deprecation/EntityLoadRector.php | 2 +- .../Rector/Deprecation/EntityManagerRector.php | 2 +- .../FunctionalTestDefaultThemePropertyRector.php | 4 ++-- .../Rector/Deprecation/LinkGeneratorTraitLRector.php | 2 +- .../Rector/Deprecation/AssertLegacyTraitRector.php | 2 +- .../Rector/Deprecation/AssertNoFieldByNameRector.php | 2 +- .../Rector/Deprecation/ExtensionPathRector.php | 2 +- .../UiHelperTraitDrupalPostFormRector.php | 2 +- .../Deprecation/MethodToMethodWithCheckRector.php | 2 +- src/Rector/PHPUnit/ShouldCallParentMethodsRector.php | 4 ++-- tests/src/Rector/Deprecation/DeprecationBase.php | 12 ++++-------- 15 files changed, 20 insertions(+), 24 deletions(-) diff --git a/src/Drupal10/Rector/Deprecation/SystemTimeZonesRector.php b/src/Drupal10/Rector/Deprecation/SystemTimeZonesRector.php index e154e402..0740f3fe 100644 --- a/src/Drupal10/Rector/Deprecation/SystemTimeZonesRector.php +++ b/src/Drupal10/Rector/Deprecation/SystemTimeZonesRector.php @@ -21,7 +21,7 @@ class SystemTimeZonesRector extends AbstractDrupalCoreRector protected array $configuration; /** - * @var \Rector\Core\PhpParser\Node\Value\ValueResolver + * @var ValueResolver */ private ValueResolver $valueResolver; diff --git a/src/Drupal8/Rector/Deprecation/DBRector.php b/src/Drupal8/Rector/Deprecation/DBRector.php index c44a85cd..2a74594e 100644 --- a/src/Drupal8/Rector/Deprecation/DBRector.php +++ b/src/Drupal8/Rector/Deprecation/DBRector.php @@ -61,7 +61,7 @@ class DBRector extends AbstractRector implements ConfigurableRectorInterface private array $configuration; /** - * @var \DrupalRector\Services\AddCommentService + * @var AddCommentService */ private AddCommentService $commentService; diff --git a/src/Drupal8/Rector/Deprecation/DrupalSetMessageRector.php b/src/Drupal8/Rector/Deprecation/DrupalSetMessageRector.php index a7c18578..641f0e40 100644 --- a/src/Drupal8/Rector/Deprecation/DrupalSetMessageRector.php +++ b/src/Drupal8/Rector/Deprecation/DrupalSetMessageRector.php @@ -36,7 +36,7 @@ final class DrupalSetMessageRector extends AbstractRector use FindParentByTypeTrait; /** - * @var \DrupalRector\Services\AddCommentService + * @var AddCommentService */ private AddCommentService $commentService; diff --git a/src/Drupal8/Rector/Deprecation/EntityInterfaceLinkRector.php b/src/Drupal8/Rector/Deprecation/EntityInterfaceLinkRector.php index 69cd36ca..c8815f48 100644 --- a/src/Drupal8/Rector/Deprecation/EntityInterfaceLinkRector.php +++ b/src/Drupal8/Rector/Deprecation/EntityInterfaceLinkRector.php @@ -24,7 +24,7 @@ final class EntityInterfaceLinkRector extends AbstractRector { /** - * @var \DrupalRector\Services\AddCommentService + * @var AddCommentService */ private AddCommentService $commentService; diff --git a/src/Drupal8/Rector/Deprecation/EntityLoadRector.php b/src/Drupal8/Rector/Deprecation/EntityLoadRector.php index 20ca3e8d..5de75256 100644 --- a/src/Drupal8/Rector/Deprecation/EntityLoadRector.php +++ b/src/Drupal8/Rector/Deprecation/EntityLoadRector.php @@ -32,7 +32,7 @@ final class EntityLoadRector extends AbstractRector implements ConfigurableRecto protected array $entityTypes; /** - * @var \DrupalRector\Services\AddCommentService + * @var AddCommentService */ private AddCommentService $commentService; diff --git a/src/Drupal8/Rector/Deprecation/EntityManagerRector.php b/src/Drupal8/Rector/Deprecation/EntityManagerRector.php index 37931121..473bbd8f 100644 --- a/src/Drupal8/Rector/Deprecation/EntityManagerRector.php +++ b/src/Drupal8/Rector/Deprecation/EntityManagerRector.php @@ -41,7 +41,7 @@ final class EntityManagerRector extends AbstractRector protected $parentClassScopeResolver; /** - * @var \DrupalRector\Services\AddCommentService + * @var AddCommentService */ private AddCommentService $commentService; diff --git a/src/Drupal8/Rector/Deprecation/FunctionalTestDefaultThemePropertyRector.php b/src/Drupal8/Rector/Deprecation/FunctionalTestDefaultThemePropertyRector.php index 26d7820e..3a0c80bd 100644 --- a/src/Drupal8/Rector/Deprecation/FunctionalTestDefaultThemePropertyRector.php +++ b/src/Drupal8/Rector/Deprecation/FunctionalTestDefaultThemePropertyRector.php @@ -24,12 +24,12 @@ final class FunctionalTestDefaultThemePropertyRector extends AbstractScopeAwareRector { /** - * @var \Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfoFactory + * @var PhpDocInfoFactory */ private PhpDocInfoFactory $phpDocInfoFactory; /** - * @var \Rector\Core\PhpParser\Node\Value\ValueResolver + * @var ValueResolver */ private ValueResolver $valueResolver; diff --git a/src/Drupal8/Rector/Deprecation/LinkGeneratorTraitLRector.php b/src/Drupal8/Rector/Deprecation/LinkGeneratorTraitLRector.php index 28fc08cb..825fa52a 100644 --- a/src/Drupal8/Rector/Deprecation/LinkGeneratorTraitLRector.php +++ b/src/Drupal8/Rector/Deprecation/LinkGeneratorTraitLRector.php @@ -28,7 +28,7 @@ final class LinkGeneratorTraitLRector extends AbstractRector use FindParentByTypeTrait; /** - * @var \DrupalRector\Services\AddCommentService + * @var AddCommentService */ private AddCommentService $commentService; diff --git a/src/Drupal9/Rector/Deprecation/AssertLegacyTraitRector.php b/src/Drupal9/Rector/Deprecation/AssertLegacyTraitRector.php index 30e6e723..02646a56 100644 --- a/src/Drupal9/Rector/Deprecation/AssertLegacyTraitRector.php +++ b/src/Drupal9/Rector/Deprecation/AssertLegacyTraitRector.php @@ -25,7 +25,7 @@ class AssertLegacyTraitRector extends AbstractRector implements ConfigurableRect private array $assertLegacyTraitMethods; /** - * @var \DrupalRector\Services\AddCommentService + * @var AddCommentService */ private AddCommentService $commentService; diff --git a/src/Drupal9/Rector/Deprecation/AssertNoFieldByNameRector.php b/src/Drupal9/Rector/Deprecation/AssertNoFieldByNameRector.php index 657724a1..863b6b21 100644 --- a/src/Drupal9/Rector/Deprecation/AssertNoFieldByNameRector.php +++ b/src/Drupal9/Rector/Deprecation/AssertNoFieldByNameRector.php @@ -22,7 +22,7 @@ final class AssertNoFieldByNameRector extends AbstractRector protected string $comment = 'Verify the assertion: buttonNotExists() if this is for a button.'; /** - * @var \DrupalRector\Services\AddCommentService + * @var AddCommentService */ private AddCommentService $commentService; diff --git a/src/Drupal9/Rector/Deprecation/ExtensionPathRector.php b/src/Drupal9/Rector/Deprecation/ExtensionPathRector.php index 836a7e9b..9bb8d50d 100644 --- a/src/Drupal9/Rector/Deprecation/ExtensionPathRector.php +++ b/src/Drupal9/Rector/Deprecation/ExtensionPathRector.php @@ -20,7 +20,7 @@ class ExtensionPathRector extends AbstractRector implements ConfigurableRectorIn private array $configuration; /** - * @var \DrupalRector\Services\AddCommentService + * @var AddCommentService */ private AddCommentService $commentService; diff --git a/src/Drupal9/Rector/Deprecation/UiHelperTraitDrupalPostFormRector.php b/src/Drupal9/Rector/Deprecation/UiHelperTraitDrupalPostFormRector.php index f2a6acf0..1adc87ec 100644 --- a/src/Drupal9/Rector/Deprecation/UiHelperTraitDrupalPostFormRector.php +++ b/src/Drupal9/Rector/Deprecation/UiHelperTraitDrupalPostFormRector.php @@ -46,7 +46,7 @@ public function getNodeTypes(): array /** * @param \PhpParser\Node\Expr\MethodCall $node * - * @throws \Rector\Core\Exception\ShouldNotHappenException + * @throws ShouldNotHappenException * * @return array */ diff --git a/src/Rector/Deprecation/MethodToMethodWithCheckRector.php b/src/Rector/Deprecation/MethodToMethodWithCheckRector.php index b99c4f3d..45ddb1c8 100644 --- a/src/Rector/Deprecation/MethodToMethodWithCheckRector.php +++ b/src/Rector/Deprecation/MethodToMethodWithCheckRector.php @@ -31,7 +31,7 @@ class MethodToMethodWithCheckRector extends AbstractRector implements Configurab private array $configuration; /** - * @var \DrupalRector\Services\AddCommentService + * @var AddCommentService */ private AddCommentService $commentService; diff --git a/src/Rector/PHPUnit/ShouldCallParentMethodsRector.php b/src/Rector/PHPUnit/ShouldCallParentMethodsRector.php index 72512166..90fe2b0c 100644 --- a/src/Rector/PHPUnit/ShouldCallParentMethodsRector.php +++ b/src/Rector/PHPUnit/ShouldCallParentMethodsRector.php @@ -22,8 +22,8 @@ public function getNodeTypes(): array /** * @phpstan-param Node\Stmt\ClassMethod $node * - * @param \PhpParser\Node $node - * @param \PHPStan\Analyser\Scope $scope + * @param Node $node + * @param Scope $scope * * @return \PhpParser\Node|null */ diff --git a/tests/src/Rector/Deprecation/DeprecationBase.php b/tests/src/Rector/Deprecation/DeprecationBase.php index 251316c7..b324f1ff 100644 --- a/tests/src/Rector/Deprecation/DeprecationBase.php +++ b/tests/src/Rector/Deprecation/DeprecationBase.php @@ -15,14 +15,10 @@ class DeprecationBase /** * Adds a class to a test. * - * @param string $rectorClass - * The class being tested - * @param \Rector\Config\RectorConfig $rectorConfig - * The Rector Config handler - * @param bool $add_config - * Indicates that config should be added to the test - * @param array $configuration - * Configuration for the configured rule + * @param string $rectorClass The class being tested + * @param RectorConfig $rectorConfig The Rector Config handler + * @param bool $add_config Indicates that config should be added to the test + * @param array $configuration Configuration for the configured rule */ public static function addClass(string $rectorClass, RectorConfig $rectorConfig, bool $add_notice_config = true, array $configuration = []) { From db8ee101a425917dbd4f0e052019a036b04828ef Mon Sep 17 00:00:00 2001 From: bjorn Date: Thu, 11 Jan 2024 08:51:20 +0100 Subject: [PATCH 10/18] feat: upgrade rector, current rector is broken with latest phpstan release See: https://github.com/rectorphp/rector/issues/8395 --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index a1f6857e..2bb3d2ea 100644 --- a/composer.json +++ b/composer.json @@ -10,7 +10,7 @@ "ast" ], "require": { - "rector/rector": "~0.18.0", + "rector/rector": "~0.19.0", "webflo/drupal-finder": "^1.2" }, "license": "MIT", From 7c10a8cd30d773e7834f50ed79a7ebcd9036d7e6 Mon Sep 17 00:00:00 2001 From: bjorn Date: Thu, 11 Jan 2024 09:50:31 +0100 Subject: [PATCH 11/18] Fixes for rector 0.19 Rector\Core -> Rector Added NodeTraverser::REMOVE_NODE to phpstan baseline since new constant is not yet available. Fixed codestyle --- phpstan-baseline.neon | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index 1ef10e01..e7a5893b 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -109,3 +109,11 @@ parameters: message: "#^Call to an undefined method PHPStan\\\\Type\\\\Type\\:\\:getValue\\(\\)\\.$#" count: 1 path: src/Drupal9/Rector/Deprecation/ExtensionPathRector.php + + - + message: """ + #^Fetching deprecated class constant REMOVE_NODE of class PhpParser\\\\NodeTraverser\\: + Use NodeVisitor\\:\\:REMOVE_NODE instead\\.$# + """ + count: 1 + path: src/Drupal9/Rector/Deprecation/PassRector.php From 4996bbe8817716d32dcab9e06cc306cfeb081417 Mon Sep 17 00:00:00 2001 From: bjorn Date: Thu, 11 Jan 2024 09:51:50 +0100 Subject: [PATCH 12/18] Fixes for rector 0.19 Rector\Core -> Rector Added NodeTraverser::REMOVE_NODE to phpstan baseline since new constant is not yet available. Fixed codestyle --- config/drupal-8/drupal-8.2-deprecations.php | 2 +- config/drupal-8/drupal-8.6-deprecations.php | 2 +- config/drupal-9/drupal-9.1-deprecations.php | 2 +- config/drupal-9/drupal-9.3-deprecations.php | 6 +++--- config/drupal-9/drupal-9.4-deprecations.php | 2 +- src/Drupal10/Rector/Deprecation/SystemTimeZonesRector.php | 2 +- .../Rector/Deprecation/ConstantToClassConstantRector.php | 4 ++-- src/Drupal8/Rector/Deprecation/DBRector.php | 4 ++-- src/Drupal8/Rector/Deprecation/DrupalLRector.php | 2 +- .../Rector/Deprecation/DrupalServiceRenameRector.php | 4 ++-- src/Drupal8/Rector/Deprecation/DrupalSetMessageRector.php | 2 +- src/Drupal8/Rector/Deprecation/DrupalURLRector.php | 2 +- src/Drupal8/Rector/Deprecation/EntityCreateRector.php | 2 +- .../Rector/Deprecation/EntityDeleteMultipleRector.php | 2 +- .../Rector/Deprecation/EntityInterfaceLinkRector.php | 2 +- src/Drupal8/Rector/Deprecation/EntityLoadRector.php | 6 +++--- src/Drupal8/Rector/Deprecation/EntityManagerRector.php | 4 ++-- src/Drupal8/Rector/Deprecation/EntityViewRector.php | 2 +- src/Drupal8/Rector/Deprecation/FileDefaultSchemeRector.php | 2 +- .../FunctionalTestDefaultThemePropertyRector.php | 6 +++--- src/Drupal8/Rector/Deprecation/GetMockRector.php | 4 ++-- .../Rector/Deprecation/LinkGeneratorTraitLRector.php | 2 +- src/Drupal8/Rector/Deprecation/RequestTimeConstRector.php | 2 +- src/Drupal8/Rector/Deprecation/SafeMarkupFormatRector.php | 2 +- src/Drupal8/Rector/Deprecation/StaticToFunctionRector.php | 4 ++-- .../Rector/ValueObject/ConstantToClassConfiguration.php | 2 +- src/Drupal8/Rector/ValueObject/EntityLoadConfiguration.php | 2 +- src/Drupal9/Rector/Deprecation/AssertFieldByIdRector.php | 2 +- src/Drupal9/Rector/Deprecation/AssertFieldByNameRector.php | 2 +- src/Drupal9/Rector/Deprecation/AssertLegacyTraitRector.php | 4 ++-- src/Drupal9/Rector/Deprecation/AssertNoFieldByIdRector.php | 2 +- .../Rector/Deprecation/AssertNoFieldByNameRector.php | 2 +- src/Drupal9/Rector/Deprecation/AssertNoUniqueTextRector.php | 4 ++-- .../Rector/Deprecation/AssertOptionSelectedRector.php | 2 +- .../Rector/Deprecation/ConstructFieldXpathRector.php | 2 +- src/Drupal9/Rector/Deprecation/ExtensionPathRector.php | 4 ++-- src/Drupal9/Rector/Deprecation/FileBuildUriRector.php | 2 +- src/Drupal9/Rector/Deprecation/FileCreateUrlRector.php | 2 +- .../Rector/Deprecation/FileUrlTransformRelativeRector.php | 2 +- src/Drupal9/Rector/Deprecation/FromUriRector.php | 2 +- .../Deprecation/FunctionToEntityTypeStorageMethod.php | 4 ++-- .../Rector/Deprecation/FunctionToFirstArgMethodRector.php | 4 ++-- src/Drupal9/Rector/Deprecation/GetAllOptionsRector.php | 2 +- src/Drupal9/Rector/Deprecation/GetRawContentRector.php | 2 +- src/Drupal9/Rector/Deprecation/ModuleLoadRector.php | 2 +- src/Drupal9/Rector/Deprecation/PassRector.php | 2 +- .../Rector/Deprecation/SystemSortByInfoNameRector.php | 2 +- .../Deprecation/TaxonomyTermLoadMultipleByNameRector.php | 2 +- .../TaxonomyVocabularyGetNamesDrupalStaticResetRector.php | 2 +- .../Rector/Deprecation/TaxonomyVocabularyGetNamesRector.php | 2 +- .../Deprecation/UiHelperTraitDrupalPostFormRector.php | 4 ++-- src/Drupal9/Rector/Deprecation/UserPasswordRector.php | 2 +- .../Property/ProtectedStaticModulesPropertyRector.php | 2 +- src/Rector/AbstractDrupalCoreRector.php | 4 ++-- src/Rector/Deprecation/Base/FunctionToFunctionBase.php | 2 +- src/Rector/Deprecation/Base/StaticToServiceBase.php | 2 +- src/Rector/Deprecation/DeprecationHelperRemoveRector.php | 4 ++-- src/Rector/Deprecation/FunctionToServiceRector.php | 4 ++-- src/Rector/Deprecation/MethodToMethodWithCheckRector.php | 6 +++--- src/Rector/PHPUnit/ShouldCallParentMethodsRector.php | 2 +- .../config/configured_rule.php | 2 +- .../config/configured_rule.php | 2 +- 62 files changed, 85 insertions(+), 85 deletions(-) diff --git a/config/drupal-8/drupal-8.2-deprecations.php b/config/drupal-8/drupal-8.2-deprecations.php index 7081b39b..439256be 100644 --- a/config/drupal-8/drupal-8.2-deprecations.php +++ b/config/drupal-8/drupal-8.2-deprecations.php @@ -12,7 +12,7 @@ }); // https://www.drupal.org/node/2802569 $rectorConfig->ruleWithConfiguration(FunctionToStaticRector::class, [ - new \DrupalRector\Rector\ValueObject\FunctionToStaticConfiguration( + new DrupalRector\Rector\ValueObject\FunctionToStaticConfiguration( '8.2.0', 'file_directory_os_temp', 'Drupal\Component\FileSystem\FileSystem', diff --git a/config/drupal-8/drupal-8.6-deprecations.php b/config/drupal-8/drupal-8.6-deprecations.php index dffe011b..34a09607 100644 --- a/config/drupal-8/drupal-8.6-deprecations.php +++ b/config/drupal-8/drupal-8.6-deprecations.php @@ -10,7 +10,7 @@ $rectorConfig->singleton(AddCommentService::class, function () { return new AddCommentService(); }); - $rectorConfig->ruleWithConfiguration(\DrupalRector\Drupal8\Rector\Deprecation\StaticToFunctionRector::class, [ + $rectorConfig->ruleWithConfiguration(DrupalRector\Drupal8\Rector\Deprecation\StaticToFunctionRector::class, [ // https://www.drupal.org/node/2850048 new StaticToFunctionConfiguration('Drupal\Component\Utility\Unicode', 'strlen', 'mb_strlen'), // https://www.drupal.org/node/2850048 diff --git a/config/drupal-9/drupal-9.1-deprecations.php b/config/drupal-9/drupal-9.1-deprecations.php index 8a6d1999..a2f5125c 100644 --- a/config/drupal-9/drupal-9.1-deprecations.php +++ b/config/drupal-9/drupal-9.1-deprecations.php @@ -42,7 +42,7 @@ $rectorConfig->rule(AssertNoFieldByNameRector::class); $rectorConfig->rule(AssertFieldByIdRector::class); - $rectorConfig->ruleWithConfiguration(\DrupalRector\Drupal9\Rector\Deprecation\AssertLegacyTraitRector::class, [ + $rectorConfig->ruleWithConfiguration(DrupalRector\Drupal9\Rector\Deprecation\AssertLegacyTraitRector::class, [ new AssertLegacyTraitConfiguration('assertLinkByHref', 'linkByHrefExists'), new AssertLegacyTraitConfiguration('assertLink', 'linkExists'), new AssertLegacyTraitConfiguration('assertNoEscaped', 'assertNoEscaped'), diff --git a/config/drupal-9/drupal-9.3-deprecations.php b/config/drupal-9/drupal-9.3-deprecations.php index 894747b8..6b6166a3 100644 --- a/config/drupal-9/drupal-9.3-deprecations.php +++ b/config/drupal-9/drupal-9.3-deprecations.php @@ -33,9 +33,9 @@ ]); // Change record: https://www.drupal.org/node/2940031 - $rectorConfig->rule(\DrupalRector\Drupal9\Rector\Deprecation\FileCreateUrlRector::class); - $rectorConfig->rule(\DrupalRector\Drupal9\Rector\Deprecation\FileUrlTransformRelativeRector::class); - $rectorConfig->rule(\DrupalRector\Drupal9\Rector\Deprecation\FromUriRector::class); + $rectorConfig->rule(DrupalRector\Drupal9\Rector\Deprecation\FileCreateUrlRector::class); + $rectorConfig->rule(DrupalRector\Drupal9\Rector\Deprecation\FileUrlTransformRelativeRector::class); + $rectorConfig->rule(DrupalRector\Drupal9\Rector\Deprecation\FromUriRector::class); // Change record: https://www.drupal.org/node/3223520 $rectorConfig->ruleWithConfiguration(FunctionToServiceRector::class, [ diff --git a/config/drupal-9/drupal-9.4-deprecations.php b/config/drupal-9/drupal-9.4-deprecations.php index 8c5ab1c2..bff0e627 100644 --- a/config/drupal-9/drupal-9.4-deprecations.php +++ b/config/drupal-9/drupal-9.4-deprecations.php @@ -4,5 +4,5 @@ return static function (Rector\Config\RectorConfig $rectorConfig): void { // Change record https://www.drupal.org/node/3220952 - $rectorConfig->rule(\DrupalRector\Drupal9\Rector\Deprecation\ModuleLoadRector::class); + $rectorConfig->rule(DrupalRector\Drupal9\Rector\Deprecation\ModuleLoadRector::class); }; diff --git a/src/Drupal10/Rector/Deprecation/SystemTimeZonesRector.php b/src/Drupal10/Rector/Deprecation/SystemTimeZonesRector.php index 0740f3fe..8299e6b2 100644 --- a/src/Drupal10/Rector/Deprecation/SystemTimeZonesRector.php +++ b/src/Drupal10/Rector/Deprecation/SystemTimeZonesRector.php @@ -9,7 +9,7 @@ use DrupalRector\Rector\ValueObject\DrupalIntroducedVersionConfiguration; use PhpParser\Node; use PhpParser\Node\Expr\ConstFetch; -use Rector\Core\PhpParser\Node\Value\ValueResolver; +use Rector\PhpParser\Node\Value\ValueResolver; use Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample; use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; diff --git a/src/Drupal8/Rector/Deprecation/ConstantToClassConstantRector.php b/src/Drupal8/Rector/Deprecation/ConstantToClassConstantRector.php index a8a6bb0e..3ee74eb7 100644 --- a/src/Drupal8/Rector/Deprecation/ConstantToClassConstantRector.php +++ b/src/Drupal8/Rector/Deprecation/ConstantToClassConstantRector.php @@ -6,8 +6,8 @@ use DrupalRector\Drupal8\Rector\ValueObject\ConstantToClassConfiguration; use PhpParser\Node; -use Rector\Core\Contract\Rector\ConfigurableRectorInterface; -use Rector\Core\Rector\AbstractRector; +use Rector\Contract\Rector\ConfigurableRectorInterface; +use Rector\Rector\AbstractRector; use Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample; use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; diff --git a/src/Drupal8/Rector/Deprecation/DBRector.php b/src/Drupal8/Rector/Deprecation/DBRector.php index 2a74594e..feb8aeb7 100644 --- a/src/Drupal8/Rector/Deprecation/DBRector.php +++ b/src/Drupal8/Rector/Deprecation/DBRector.php @@ -9,8 +9,8 @@ use PhpParser\Node; use PhpParser\Node\Expr; use PhpParser\Node\Expr\MethodCall; -use Rector\Core\Contract\Rector\ConfigurableRectorInterface; -use Rector\Core\Rector\AbstractRector; +use Rector\Contract\Rector\ConfigurableRectorInterface; +use Rector\Rector\AbstractRector; use Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample; use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; diff --git a/src/Drupal8/Rector/Deprecation/DrupalLRector.php b/src/Drupal8/Rector/Deprecation/DrupalLRector.php index 3852086f..ce176653 100644 --- a/src/Drupal8/Rector/Deprecation/DrupalLRector.php +++ b/src/Drupal8/Rector/Deprecation/DrupalLRector.php @@ -5,7 +5,7 @@ namespace DrupalRector\Drupal8\Rector\Deprecation; use PhpParser\Node; -use Rector\Core\Rector\AbstractRector; +use Rector\Rector\AbstractRector; use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; diff --git a/src/Drupal8/Rector/Deprecation/DrupalServiceRenameRector.php b/src/Drupal8/Rector/Deprecation/DrupalServiceRenameRector.php index de2c0b60..43726353 100644 --- a/src/Drupal8/Rector/Deprecation/DrupalServiceRenameRector.php +++ b/src/Drupal8/Rector/Deprecation/DrupalServiceRenameRector.php @@ -6,8 +6,8 @@ use DrupalRector\Drupal8\Rector\ValueObject\DrupalServiceRenameConfiguration; use PhpParser\Node; -use Rector\Core\Contract\Rector\ConfigurableRectorInterface; -use Rector\Core\Rector\AbstractRector; +use Rector\Contract\Rector\ConfigurableRectorInterface; +use Rector\Rector\AbstractRector; use Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample; use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; diff --git a/src/Drupal8/Rector/Deprecation/DrupalSetMessageRector.php b/src/Drupal8/Rector/Deprecation/DrupalSetMessageRector.php index 641f0e40..4d3addba 100644 --- a/src/Drupal8/Rector/Deprecation/DrupalSetMessageRector.php +++ b/src/Drupal8/Rector/Deprecation/DrupalSetMessageRector.php @@ -11,8 +11,8 @@ use PHPStan\PhpDocParser\Ast\PhpDoc\GenericTagValueNode; use PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagNode; use Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo; -use Rector\Core\Rector\AbstractRector; use Rector\NodeTypeResolver\Node\AttributeKey; +use Rector\Rector\AbstractRector; use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; diff --git a/src/Drupal8/Rector/Deprecation/DrupalURLRector.php b/src/Drupal8/Rector/Deprecation/DrupalURLRector.php index d560e90b..59c799f1 100644 --- a/src/Drupal8/Rector/Deprecation/DrupalURLRector.php +++ b/src/Drupal8/Rector/Deprecation/DrupalURLRector.php @@ -5,7 +5,7 @@ namespace DrupalRector\Drupal8\Rector\Deprecation; use PhpParser\Node; -use Rector\Core\Rector\AbstractRector; +use Rector\Rector\AbstractRector; use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; diff --git a/src/Drupal8/Rector/Deprecation/EntityCreateRector.php b/src/Drupal8/Rector/Deprecation/EntityCreateRector.php index 6dec3a4a..8570c6f9 100644 --- a/src/Drupal8/Rector/Deprecation/EntityCreateRector.php +++ b/src/Drupal8/Rector/Deprecation/EntityCreateRector.php @@ -5,7 +5,7 @@ namespace DrupalRector\Drupal8\Rector\Deprecation; use PhpParser\Node; -use Rector\Core\Rector\AbstractRector; +use Rector\Rector\AbstractRector; use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; diff --git a/src/Drupal8/Rector/Deprecation/EntityDeleteMultipleRector.php b/src/Drupal8/Rector/Deprecation/EntityDeleteMultipleRector.php index 64205e96..18cbf65b 100644 --- a/src/Drupal8/Rector/Deprecation/EntityDeleteMultipleRector.php +++ b/src/Drupal8/Rector/Deprecation/EntityDeleteMultipleRector.php @@ -5,7 +5,7 @@ namespace DrupalRector\Drupal8\Rector\Deprecation; use PhpParser\Node; -use Rector\Core\Rector\AbstractRector; +use Rector\Rector\AbstractRector; use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; diff --git a/src/Drupal8/Rector/Deprecation/EntityInterfaceLinkRector.php b/src/Drupal8/Rector/Deprecation/EntityInterfaceLinkRector.php index c8815f48..31b85b90 100644 --- a/src/Drupal8/Rector/Deprecation/EntityInterfaceLinkRector.php +++ b/src/Drupal8/Rector/Deprecation/EntityInterfaceLinkRector.php @@ -6,7 +6,7 @@ use DrupalRector\Services\AddCommentService; use PhpParser\Node; -use Rector\Core\Rector\AbstractRector; +use Rector\Rector\AbstractRector; use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; diff --git a/src/Drupal8/Rector/Deprecation/EntityLoadRector.php b/src/Drupal8/Rector/Deprecation/EntityLoadRector.php index 5de75256..3e7dd9e9 100644 --- a/src/Drupal8/Rector/Deprecation/EntityLoadRector.php +++ b/src/Drupal8/Rector/Deprecation/EntityLoadRector.php @@ -7,8 +7,8 @@ use DrupalRector\Drupal8\Rector\ValueObject\EntityLoadConfiguration; use DrupalRector\Services\AddCommentService; use PhpParser\Node; -use Rector\Core\Contract\Rector\ConfigurableRectorInterface; -use Rector\Core\Rector\AbstractRector; +use Rector\Contract\Rector\ConfigurableRectorInterface; +use Rector\Rector\AbstractRector; use Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample; use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; @@ -171,7 +171,7 @@ public function refactor(Node $node): ?Node $reset_args = [ // This creates a new argument that wraps the entity ID in an array. - new Node\Arg(new Node\Expr\Array_([new Node\Expr\ArrayItem($entity_id->value)])), + new Node\Arg(new Node\Expr\Array_([new \PhpParser\Node\ArrayItem($entity_id->value)])), ]; $entity_load_reset_node = new Node\Expr\MethodCall($getStorage_node, diff --git a/src/Drupal8/Rector/Deprecation/EntityManagerRector.php b/src/Drupal8/Rector/Deprecation/EntityManagerRector.php index 473bbd8f..9b26d5b6 100644 --- a/src/Drupal8/Rector/Deprecation/EntityManagerRector.php +++ b/src/Drupal8/Rector/Deprecation/EntityManagerRector.php @@ -7,10 +7,10 @@ use DrupalRector\Services\AddCommentService; use PhpParser\Node; use PHPStan\Analyser\Scope; -use Rector\Core\Exception\ShouldNotHappenException; -use Rector\Core\Rector\AbstractRector; +use Rector\Exception\ShouldNotHappenException; use Rector\NodeCollector\ScopeResolver\ParentClassScopeResolver; use Rector\NodeTypeResolver\Node\AttributeKey; +use Rector\Rector\AbstractRector; use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; diff --git a/src/Drupal8/Rector/Deprecation/EntityViewRector.php b/src/Drupal8/Rector/Deprecation/EntityViewRector.php index 1a602de1..26e035b1 100644 --- a/src/Drupal8/Rector/Deprecation/EntityViewRector.php +++ b/src/Drupal8/Rector/Deprecation/EntityViewRector.php @@ -5,7 +5,7 @@ namespace DrupalRector\Drupal8\Rector\Deprecation; use PhpParser\Node; -use Rector\Core\Rector\AbstractRector; +use Rector\Rector\AbstractRector; use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; diff --git a/src/Drupal8/Rector/Deprecation/FileDefaultSchemeRector.php b/src/Drupal8/Rector/Deprecation/FileDefaultSchemeRector.php index 224df6f0..2d98cd86 100644 --- a/src/Drupal8/Rector/Deprecation/FileDefaultSchemeRector.php +++ b/src/Drupal8/Rector/Deprecation/FileDefaultSchemeRector.php @@ -5,7 +5,7 @@ namespace DrupalRector\Drupal8\Rector\Deprecation; use PhpParser\Node; -use Rector\Core\Rector\AbstractRector; +use Rector\Rector\AbstractRector; use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; diff --git a/src/Drupal8/Rector/Deprecation/FunctionalTestDefaultThemePropertyRector.php b/src/Drupal8/Rector/Deprecation/FunctionalTestDefaultThemePropertyRector.php index 3a0c80bd..68316c57 100644 --- a/src/Drupal8/Rector/Deprecation/FunctionalTestDefaultThemePropertyRector.php +++ b/src/Drupal8/Rector/Deprecation/FunctionalTestDefaultThemePropertyRector.php @@ -10,9 +10,9 @@ use PHPStan\Analyser\Scope; use PHPStan\Type\ObjectType; use Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfoFactory; -use Rector\Core\Exception\ShouldNotHappenException; -use Rector\Core\PhpParser\Node\Value\ValueResolver; -use Rector\Core\Rector\AbstractScopeAwareRector; +use Rector\Exception\ShouldNotHappenException; +use Rector\PhpParser\Node\Value\ValueResolver; +use Rector\Rector\AbstractScopeAwareRector; use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; diff --git a/src/Drupal8/Rector/Deprecation/GetMockRector.php b/src/Drupal8/Rector/Deprecation/GetMockRector.php index a30f3f1e..2f9f673d 100644 --- a/src/Drupal8/Rector/Deprecation/GetMockRector.php +++ b/src/Drupal8/Rector/Deprecation/GetMockRector.php @@ -7,10 +7,10 @@ use DrupalRector\Drupal8\Rector\ValueObject\GetMockConfiguration; use PhpParser\Node; use PHPStan\Analyser\Scope; -use Rector\Core\Contract\Rector\ConfigurableRectorInterface; -use Rector\Core\Rector\AbstractRector; +use Rector\Contract\Rector\ConfigurableRectorInterface; use Rector\NodeCollector\ScopeResolver\ParentClassScopeResolver; use Rector\NodeTypeResolver\Node\AttributeKey; +use Rector\Rector\AbstractRector; use Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample; use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; diff --git a/src/Drupal8/Rector/Deprecation/LinkGeneratorTraitLRector.php b/src/Drupal8/Rector/Deprecation/LinkGeneratorTraitLRector.php index 825fa52a..4195de5c 100644 --- a/src/Drupal8/Rector/Deprecation/LinkGeneratorTraitLRector.php +++ b/src/Drupal8/Rector/Deprecation/LinkGeneratorTraitLRector.php @@ -7,8 +7,8 @@ use DrupalRector\Services\AddCommentService; use DrupalRector\Utility\FindParentByTypeTrait; use PhpParser\Node; -use Rector\Core\Rector\AbstractRector; use Rector\NodeTypeResolver\Node\AttributeKey; +use Rector\Rector\AbstractRector; use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; diff --git a/src/Drupal8/Rector/Deprecation/RequestTimeConstRector.php b/src/Drupal8/Rector/Deprecation/RequestTimeConstRector.php index 8a98da03..526f61b8 100644 --- a/src/Drupal8/Rector/Deprecation/RequestTimeConstRector.php +++ b/src/Drupal8/Rector/Deprecation/RequestTimeConstRector.php @@ -5,7 +5,7 @@ namespace DrupalRector\Drupal8\Rector\Deprecation; use PhpParser\Node; -use Rector\Core\Rector\AbstractRector; +use Rector\Rector\AbstractRector; use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; diff --git a/src/Drupal8/Rector/Deprecation/SafeMarkupFormatRector.php b/src/Drupal8/Rector/Deprecation/SafeMarkupFormatRector.php index 5bf6b0fa..d59b7acd 100644 --- a/src/Drupal8/Rector/Deprecation/SafeMarkupFormatRector.php +++ b/src/Drupal8/Rector/Deprecation/SafeMarkupFormatRector.php @@ -5,7 +5,7 @@ namespace DrupalRector\Drupal8\Rector\Deprecation; use PhpParser\Node; -use Rector\Core\Rector\AbstractRector; +use Rector\Rector\AbstractRector; use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; diff --git a/src/Drupal8/Rector/Deprecation/StaticToFunctionRector.php b/src/Drupal8/Rector/Deprecation/StaticToFunctionRector.php index 52ef5b9a..59ab837e 100644 --- a/src/Drupal8/Rector/Deprecation/StaticToFunctionRector.php +++ b/src/Drupal8/Rector/Deprecation/StaticToFunctionRector.php @@ -6,8 +6,8 @@ use DrupalRector\Drupal8\Rector\ValueObject\StaticToFunctionConfiguration; use PhpParser\Node; -use Rector\Core\Contract\Rector\ConfigurableRectorInterface; -use Rector\Core\Rector\AbstractRector; +use Rector\Contract\Rector\ConfigurableRectorInterface; +use Rector\Rector\AbstractRector; use Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample; use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; diff --git a/src/Drupal8/Rector/ValueObject/ConstantToClassConfiguration.php b/src/Drupal8/Rector/ValueObject/ConstantToClassConfiguration.php index 131274be..b8bfe544 100644 --- a/src/Drupal8/Rector/ValueObject/ConstantToClassConfiguration.php +++ b/src/Drupal8/Rector/ValueObject/ConstantToClassConfiguration.php @@ -4,7 +4,7 @@ namespace DrupalRector\Drupal8\Rector\ValueObject; -use Rector\Core\Validation\RectorAssert; +use Rector\Validation\RectorAssert; final class ConstantToClassConfiguration { diff --git a/src/Drupal8/Rector/ValueObject/EntityLoadConfiguration.php b/src/Drupal8/Rector/ValueObject/EntityLoadConfiguration.php index f5b96729..bdf2aa4f 100644 --- a/src/Drupal8/Rector/ValueObject/EntityLoadConfiguration.php +++ b/src/Drupal8/Rector/ValueObject/EntityLoadConfiguration.php @@ -4,7 +4,7 @@ namespace DrupalRector\Drupal8\Rector\ValueObject; -use Rector\Core\Validation\RectorAssert; +use Rector\Validation\RectorAssert; final class EntityLoadConfiguration { diff --git a/src/Drupal9/Rector/Deprecation/AssertFieldByIdRector.php b/src/Drupal9/Rector/Deprecation/AssertFieldByIdRector.php index 5fc330d4..677f5355 100644 --- a/src/Drupal9/Rector/Deprecation/AssertFieldByIdRector.php +++ b/src/Drupal9/Rector/Deprecation/AssertFieldByIdRector.php @@ -5,7 +5,7 @@ namespace DrupalRector\Drupal9\Rector\Deprecation; use PhpParser\Node; -use Rector\Core\Rector\AbstractRector; +use Rector\Rector\AbstractRector; use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; diff --git a/src/Drupal9/Rector/Deprecation/AssertFieldByNameRector.php b/src/Drupal9/Rector/Deprecation/AssertFieldByNameRector.php index 6200835a..69ca6451 100644 --- a/src/Drupal9/Rector/Deprecation/AssertFieldByNameRector.php +++ b/src/Drupal9/Rector/Deprecation/AssertFieldByNameRector.php @@ -5,7 +5,7 @@ namespace DrupalRector\Drupal9\Rector\Deprecation; use PhpParser\Node; -use Rector\Core\Rector\AbstractRector; +use Rector\Rector\AbstractRector; use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; diff --git a/src/Drupal9/Rector/Deprecation/AssertLegacyTraitRector.php b/src/Drupal9/Rector/Deprecation/AssertLegacyTraitRector.php index 02646a56..95e3a374 100644 --- a/src/Drupal9/Rector/Deprecation/AssertLegacyTraitRector.php +++ b/src/Drupal9/Rector/Deprecation/AssertLegacyTraitRector.php @@ -10,8 +10,8 @@ use PhpParser\Node; use PhpParser\Node\Arg; use PhpParser\Node\VariadicPlaceholder; -use Rector\Core\Contract\Rector\ConfigurableRectorInterface; -use Rector\Core\Rector\AbstractRector; +use Rector\Contract\Rector\ConfigurableRectorInterface; +use Rector\Rector\AbstractRector; use Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample; use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; diff --git a/src/Drupal9/Rector/Deprecation/AssertNoFieldByIdRector.php b/src/Drupal9/Rector/Deprecation/AssertNoFieldByIdRector.php index 77934191..202a8b27 100644 --- a/src/Drupal9/Rector/Deprecation/AssertNoFieldByIdRector.php +++ b/src/Drupal9/Rector/Deprecation/AssertNoFieldByIdRector.php @@ -5,7 +5,7 @@ namespace DrupalRector\Drupal9\Rector\Deprecation; use PhpParser\Node; -use Rector\Core\Rector\AbstractRector; +use Rector\Rector\AbstractRector; use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; diff --git a/src/Drupal9/Rector/Deprecation/AssertNoFieldByNameRector.php b/src/Drupal9/Rector/Deprecation/AssertNoFieldByNameRector.php index 863b6b21..72fc873a 100644 --- a/src/Drupal9/Rector/Deprecation/AssertNoFieldByNameRector.php +++ b/src/Drupal9/Rector/Deprecation/AssertNoFieldByNameRector.php @@ -9,7 +9,7 @@ use PhpParser\Node; use PhpParser\Node\Arg; use PhpParser\Node\VariadicPlaceholder; -use Rector\Core\Rector\AbstractRector; +use Rector\Rector\AbstractRector; use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; diff --git a/src/Drupal9/Rector/Deprecation/AssertNoUniqueTextRector.php b/src/Drupal9/Rector/Deprecation/AssertNoUniqueTextRector.php index 6407459c..caabeefa 100644 --- a/src/Drupal9/Rector/Deprecation/AssertNoUniqueTextRector.php +++ b/src/Drupal9/Rector/Deprecation/AssertNoUniqueTextRector.php @@ -6,8 +6,8 @@ use DrupalRector\Utility\GetDeclaringSourceTrait; use PhpParser\Node; -use Rector\Core\Exception\ShouldNotHappenException; -use Rector\Core\Rector\AbstractRector; +use Rector\Exception\ShouldNotHappenException; +use Rector\Rector\AbstractRector; use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; diff --git a/src/Drupal9/Rector/Deprecation/AssertOptionSelectedRector.php b/src/Drupal9/Rector/Deprecation/AssertOptionSelectedRector.php index b090a2ab..09b7ae71 100644 --- a/src/Drupal9/Rector/Deprecation/AssertOptionSelectedRector.php +++ b/src/Drupal9/Rector/Deprecation/AssertOptionSelectedRector.php @@ -5,7 +5,7 @@ namespace DrupalRector\Drupal9\Rector\Deprecation; use PhpParser\Node; -use Rector\Core\Rector\AbstractRector; +use Rector\Rector\AbstractRector; use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; diff --git a/src/Drupal9/Rector/Deprecation/ConstructFieldXpathRector.php b/src/Drupal9/Rector/Deprecation/ConstructFieldXpathRector.php index 1de4caff..f6c9b14e 100644 --- a/src/Drupal9/Rector/Deprecation/ConstructFieldXpathRector.php +++ b/src/Drupal9/Rector/Deprecation/ConstructFieldXpathRector.php @@ -6,7 +6,7 @@ use DrupalRector\Utility\GetDeclaringSourceTrait; use PhpParser\Node; -use Rector\Core\Rector\AbstractRector; +use Rector\Rector\AbstractRector; use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; diff --git a/src/Drupal9/Rector/Deprecation/ExtensionPathRector.php b/src/Drupal9/Rector/Deprecation/ExtensionPathRector.php index 9bb8d50d..e0d9ca33 100644 --- a/src/Drupal9/Rector/Deprecation/ExtensionPathRector.php +++ b/src/Drupal9/Rector/Deprecation/ExtensionPathRector.php @@ -7,8 +7,8 @@ use DrupalRector\Drupal9\Rector\ValueObject\ExtensionPathConfiguration; use DrupalRector\Services\AddCommentService; use PhpParser\Node; -use Rector\Core\Contract\Rector\ConfigurableRectorInterface; -use Rector\Core\Rector\AbstractRector; +use Rector\Contract\Rector\ConfigurableRectorInterface; +use Rector\Rector\AbstractRector; use Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample; use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; diff --git a/src/Drupal9/Rector/Deprecation/FileBuildUriRector.php b/src/Drupal9/Rector/Deprecation/FileBuildUriRector.php index 57864646..8ebefe34 100644 --- a/src/Drupal9/Rector/Deprecation/FileBuildUriRector.php +++ b/src/Drupal9/Rector/Deprecation/FileBuildUriRector.php @@ -5,7 +5,7 @@ namespace DrupalRector\Drupal9\Rector\Deprecation; use PhpParser\Node; -use Rector\Core\Rector\AbstractRector; +use Rector\Rector\AbstractRector; use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; diff --git a/src/Drupal9/Rector/Deprecation/FileCreateUrlRector.php b/src/Drupal9/Rector/Deprecation/FileCreateUrlRector.php index bfd72b0f..1054a6d1 100644 --- a/src/Drupal9/Rector/Deprecation/FileCreateUrlRector.php +++ b/src/Drupal9/Rector/Deprecation/FileCreateUrlRector.php @@ -5,7 +5,7 @@ namespace DrupalRector\Drupal9\Rector\Deprecation; use PhpParser\Node; -use Rector\Core\Rector\AbstractRector; +use Rector\Rector\AbstractRector; use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; diff --git a/src/Drupal9/Rector/Deprecation/FileUrlTransformRelativeRector.php b/src/Drupal9/Rector/Deprecation/FileUrlTransformRelativeRector.php index b6896ab4..1fa90220 100644 --- a/src/Drupal9/Rector/Deprecation/FileUrlTransformRelativeRector.php +++ b/src/Drupal9/Rector/Deprecation/FileUrlTransformRelativeRector.php @@ -5,7 +5,7 @@ namespace DrupalRector\Drupal9\Rector\Deprecation; use PhpParser\Node; -use Rector\Core\Rector\AbstractRector; +use Rector\Rector\AbstractRector; use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; diff --git a/src/Drupal9/Rector/Deprecation/FromUriRector.php b/src/Drupal9/Rector/Deprecation/FromUriRector.php index 891b6ea6..f88f83e7 100644 --- a/src/Drupal9/Rector/Deprecation/FromUriRector.php +++ b/src/Drupal9/Rector/Deprecation/FromUriRector.php @@ -6,7 +6,7 @@ use DrupalRector\Utility\GetDeclaringSourceTrait; use PhpParser\Node; -use Rector\Core\Rector\AbstractRector; +use Rector\Rector\AbstractRector; use Rector\StaticTypeMapper\ValueObject\Type\FullyQualifiedObjectType; use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; diff --git a/src/Drupal9/Rector/Deprecation/FunctionToEntityTypeStorageMethod.php b/src/Drupal9/Rector/Deprecation/FunctionToEntityTypeStorageMethod.php index 84619b7d..74c02230 100644 --- a/src/Drupal9/Rector/Deprecation/FunctionToEntityTypeStorageMethod.php +++ b/src/Drupal9/Rector/Deprecation/FunctionToEntityTypeStorageMethod.php @@ -6,8 +6,8 @@ use DrupalRector\Drupal9\Rector\ValueObject\FunctionToEntityTypeStorageConfiguration; use PhpParser\Node; -use Rector\Core\Contract\Rector\ConfigurableRectorInterface; -use Rector\Core\Rector\AbstractRector; +use Rector\Contract\Rector\ConfigurableRectorInterface; +use Rector\Rector\AbstractRector; use Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample; use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; diff --git a/src/Drupal9/Rector/Deprecation/FunctionToFirstArgMethodRector.php b/src/Drupal9/Rector/Deprecation/FunctionToFirstArgMethodRector.php index 240253a0..7a89089e 100644 --- a/src/Drupal9/Rector/Deprecation/FunctionToFirstArgMethodRector.php +++ b/src/Drupal9/Rector/Deprecation/FunctionToFirstArgMethodRector.php @@ -6,8 +6,8 @@ use DrupalRector\Drupal9\Rector\ValueObject\FunctionToFirstArgMethodConfiguration; use PhpParser\Node; -use Rector\Core\Contract\Rector\ConfigurableRectorInterface; -use Rector\Core\Rector\AbstractRector; +use Rector\Contract\Rector\ConfigurableRectorInterface; +use Rector\Rector\AbstractRector; use Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample; use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; diff --git a/src/Drupal9/Rector/Deprecation/GetAllOptionsRector.php b/src/Drupal9/Rector/Deprecation/GetAllOptionsRector.php index 9038a88b..68a57c69 100644 --- a/src/Drupal9/Rector/Deprecation/GetAllOptionsRector.php +++ b/src/Drupal9/Rector/Deprecation/GetAllOptionsRector.php @@ -6,8 +6,8 @@ use DrupalRector\Utility\GetDeclaringSourceTrait; use PhpParser\Node; -use Rector\Core\Rector\AbstractRector; use Rector\NodeCollector\ScopeResolver\ParentClassScopeResolver; +use Rector\Rector\AbstractRector; use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; diff --git a/src/Drupal9/Rector/Deprecation/GetRawContentRector.php b/src/Drupal9/Rector/Deprecation/GetRawContentRector.php index a0425cef..cf6d9dcb 100644 --- a/src/Drupal9/Rector/Deprecation/GetRawContentRector.php +++ b/src/Drupal9/Rector/Deprecation/GetRawContentRector.php @@ -6,8 +6,8 @@ use DrupalRector\Utility\GetDeclaringSourceTrait; use PhpParser\Node; -use Rector\Core\Rector\AbstractRector; use Rector\NodeCollector\ScopeResolver\ParentClassScopeResolver; +use Rector\Rector\AbstractRector; use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; diff --git a/src/Drupal9/Rector/Deprecation/ModuleLoadRector.php b/src/Drupal9/Rector/Deprecation/ModuleLoadRector.php index 866623ae..37c38d55 100644 --- a/src/Drupal9/Rector/Deprecation/ModuleLoadRector.php +++ b/src/Drupal9/Rector/Deprecation/ModuleLoadRector.php @@ -5,7 +5,7 @@ namespace DrupalRector\Drupal9\Rector\Deprecation; use PhpParser\Node; -use Rector\Core\Rector\AbstractRector; +use Rector\Rector\AbstractRector; use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; diff --git a/src/Drupal9/Rector/Deprecation/PassRector.php b/src/Drupal9/Rector/Deprecation/PassRector.php index 7b12b400..60b68900 100644 --- a/src/Drupal9/Rector/Deprecation/PassRector.php +++ b/src/Drupal9/Rector/Deprecation/PassRector.php @@ -7,7 +7,7 @@ use DrupalRector\Utility\GetDeclaringSourceTrait; use PhpParser\Node; use PhpParser\NodeTraverser; -use Rector\Core\Rector\AbstractRector; +use Rector\Rector\AbstractRector; use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; diff --git a/src/Drupal9/Rector/Deprecation/SystemSortByInfoNameRector.php b/src/Drupal9/Rector/Deprecation/SystemSortByInfoNameRector.php index c30334f3..b99f44e4 100644 --- a/src/Drupal9/Rector/Deprecation/SystemSortByInfoNameRector.php +++ b/src/Drupal9/Rector/Deprecation/SystemSortByInfoNameRector.php @@ -5,7 +5,7 @@ namespace DrupalRector\Drupal9\Rector\Deprecation; use PhpParser\Node; -use Rector\Core\Rector\AbstractRector; +use Rector\Rector\AbstractRector; use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; diff --git a/src/Drupal9/Rector/Deprecation/TaxonomyTermLoadMultipleByNameRector.php b/src/Drupal9/Rector/Deprecation/TaxonomyTermLoadMultipleByNameRector.php index 9e69b2e1..37be4883 100644 --- a/src/Drupal9/Rector/Deprecation/TaxonomyTermLoadMultipleByNameRector.php +++ b/src/Drupal9/Rector/Deprecation/TaxonomyTermLoadMultipleByNameRector.php @@ -5,7 +5,7 @@ namespace DrupalRector\Drupal9\Rector\Deprecation; use PhpParser\Node; -use Rector\Core\Rector\AbstractRector; +use Rector\Rector\AbstractRector; use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; diff --git a/src/Drupal9/Rector/Deprecation/TaxonomyVocabularyGetNamesDrupalStaticResetRector.php b/src/Drupal9/Rector/Deprecation/TaxonomyVocabularyGetNamesDrupalStaticResetRector.php index 8579d38a..85843ad4 100644 --- a/src/Drupal9/Rector/Deprecation/TaxonomyVocabularyGetNamesDrupalStaticResetRector.php +++ b/src/Drupal9/Rector/Deprecation/TaxonomyVocabularyGetNamesDrupalStaticResetRector.php @@ -5,7 +5,7 @@ namespace DrupalRector\Drupal9\Rector\Deprecation; use PhpParser\Node; -use Rector\Core\Rector\AbstractRector; +use Rector\Rector\AbstractRector; use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; diff --git a/src/Drupal9/Rector/Deprecation/TaxonomyVocabularyGetNamesRector.php b/src/Drupal9/Rector/Deprecation/TaxonomyVocabularyGetNamesRector.php index a8d525e0..d19ba3f1 100644 --- a/src/Drupal9/Rector/Deprecation/TaxonomyVocabularyGetNamesRector.php +++ b/src/Drupal9/Rector/Deprecation/TaxonomyVocabularyGetNamesRector.php @@ -5,7 +5,7 @@ namespace DrupalRector\Drupal9\Rector\Deprecation; use PhpParser\Node; -use Rector\Core\Rector\AbstractRector; +use Rector\Rector\AbstractRector; use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; diff --git a/src/Drupal9/Rector/Deprecation/UiHelperTraitDrupalPostFormRector.php b/src/Drupal9/Rector/Deprecation/UiHelperTraitDrupalPostFormRector.php index 1adc87ec..eb2a9421 100644 --- a/src/Drupal9/Rector/Deprecation/UiHelperTraitDrupalPostFormRector.php +++ b/src/Drupal9/Rector/Deprecation/UiHelperTraitDrupalPostFormRector.php @@ -5,8 +5,8 @@ namespace DrupalRector\Drupal9\Rector\Deprecation; use PhpParser\Node; -use Rector\Core\Exception\ShouldNotHappenException; -use Rector\Core\Rector\AbstractRector; +use Rector\Exception\ShouldNotHappenException; +use Rector\Rector\AbstractRector; use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; diff --git a/src/Drupal9/Rector/Deprecation/UserPasswordRector.php b/src/Drupal9/Rector/Deprecation/UserPasswordRector.php index 19ba03af..e6c10d26 100644 --- a/src/Drupal9/Rector/Deprecation/UserPasswordRector.php +++ b/src/Drupal9/Rector/Deprecation/UserPasswordRector.php @@ -5,7 +5,7 @@ namespace DrupalRector\Drupal9\Rector\Deprecation; use PhpParser\Node; -use Rector\Core\Rector\AbstractRector; +use Rector\Rector\AbstractRector; use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; diff --git a/src/Drupal9/Rector/Property/ProtectedStaticModulesPropertyRector.php b/src/Drupal9/Rector/Property/ProtectedStaticModulesPropertyRector.php index 72dba517..b7a6ae09 100644 --- a/src/Drupal9/Rector/Property/ProtectedStaticModulesPropertyRector.php +++ b/src/Drupal9/Rector/Property/ProtectedStaticModulesPropertyRector.php @@ -5,8 +5,8 @@ namespace DrupalRector\Drupal9\Rector\Property; use PhpParser\Node; -use Rector\Core\Rector\AbstractRector; use Rector\Privatization\NodeManipulator\VisibilityManipulator; +use Rector\Rector\AbstractRector; use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; diff --git a/src/Rector/AbstractDrupalCoreRector.php b/src/Rector/AbstractDrupalCoreRector.php index 54f857da..d95f1205 100644 --- a/src/Rector/AbstractDrupalCoreRector.php +++ b/src/Rector/AbstractDrupalCoreRector.php @@ -8,8 +8,8 @@ use DrupalRector\Contract\VersionedConfigurationInterface; use PhpParser\Node; use PhpParser\Node\Expr\ArrowFunction; -use Rector\Core\Contract\Rector\ConfigurableRectorInterface; -use Rector\Core\Rector\AbstractRector; +use Rector\Contract\Rector\ConfigurableRectorInterface; +use Rector\Rector\AbstractRector; abstract class AbstractDrupalCoreRector extends AbstractRector implements ConfigurableRectorInterface { diff --git a/src/Rector/Deprecation/Base/FunctionToFunctionBase.php b/src/Rector/Deprecation/Base/FunctionToFunctionBase.php index 92b90c27..8d2ce507 100644 --- a/src/Rector/Deprecation/Base/FunctionToFunctionBase.php +++ b/src/Rector/Deprecation/Base/FunctionToFunctionBase.php @@ -5,7 +5,7 @@ namespace DrupalRector\Rector\Deprecation\Base; use PhpParser\Node; -use Rector\Core\Rector\AbstractRector; +use Rector\Rector\AbstractRector; /** * Replaces deprecated function call with a function call. diff --git a/src/Rector/Deprecation/Base/StaticToServiceBase.php b/src/Rector/Deprecation/Base/StaticToServiceBase.php index fb185a3e..618399d5 100644 --- a/src/Rector/Deprecation/Base/StaticToServiceBase.php +++ b/src/Rector/Deprecation/Base/StaticToServiceBase.php @@ -5,7 +5,7 @@ namespace DrupalRector\Rector\Deprecation\Base; use PhpParser\Node; -use Rector\Core\Rector\AbstractRector; +use Rector\Rector\AbstractRector; /** * Replaces deprecated static call with service method call. diff --git a/src/Rector/Deprecation/DeprecationHelperRemoveRector.php b/src/Rector/Deprecation/DeprecationHelperRemoveRector.php index af240ea2..2cc66505 100644 --- a/src/Rector/Deprecation/DeprecationHelperRemoveRector.php +++ b/src/Rector/Deprecation/DeprecationHelperRemoveRector.php @@ -6,8 +6,8 @@ use DrupalRector\Rector\ValueObject\DeprecationHelperRemoveConfiguration; use PhpParser\Node; -use Rector\Core\Contract\Rector\ConfigurableRectorInterface; -use Rector\Core\Rector\AbstractRector; +use Rector\Contract\Rector\ConfigurableRectorInterface; +use Rector\Rector\AbstractRector; use Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample; use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; diff --git a/src/Rector/Deprecation/FunctionToServiceRector.php b/src/Rector/Deprecation/FunctionToServiceRector.php index 124e0e4a..3465c936 100644 --- a/src/Rector/Deprecation/FunctionToServiceRector.php +++ b/src/Rector/Deprecation/FunctionToServiceRector.php @@ -6,8 +6,8 @@ use DrupalRector\Rector\ValueObject\FunctionToServiceConfiguration; use PhpParser\Node; -use Rector\Core\Contract\Rector\ConfigurableRectorInterface; -use Rector\Core\Rector\AbstractRector; +use Rector\Contract\Rector\ConfigurableRectorInterface; +use Rector\Rector\AbstractRector; use Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample; use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; diff --git a/src/Rector/Deprecation/MethodToMethodWithCheckRector.php b/src/Rector/Deprecation/MethodToMethodWithCheckRector.php index 45ddb1c8..409feee4 100644 --- a/src/Rector/Deprecation/MethodToMethodWithCheckRector.php +++ b/src/Rector/Deprecation/MethodToMethodWithCheckRector.php @@ -8,9 +8,9 @@ use DrupalRector\Services\AddCommentService; use PhpParser\Node; use PHPStan\Type\ObjectType; -use Rector\Core\Contract\Rector\ConfigurableRectorInterface; -use Rector\Core\Exception\ShouldNotHappenException; -use Rector\Core\Rector\AbstractRector; +use Rector\Contract\Rector\ConfigurableRectorInterface; +use Rector\Exception\ShouldNotHappenException; +use Rector\Rector\AbstractRector; use Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample; use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; diff --git a/src/Rector/PHPUnit/ShouldCallParentMethodsRector.php b/src/Rector/PHPUnit/ShouldCallParentMethodsRector.php index 90fe2b0c..934ef7fa 100644 --- a/src/Rector/PHPUnit/ShouldCallParentMethodsRector.php +++ b/src/Rector/PHPUnit/ShouldCallParentMethodsRector.php @@ -6,7 +6,7 @@ use PhpParser\Node; use PHPStan\Analyser\Scope; -use Rector\Core\Rector\AbstractScopeAwareRector; +use Rector\Rector\AbstractScopeAwareRector; use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; diff --git a/tests/src/Drupal8/Rector/Deprecation/FunctionalTestDefaultThemePropertyRector/config/configured_rule.php b/tests/src/Drupal8/Rector/Deprecation/FunctionalTestDefaultThemePropertyRector/config/configured_rule.php index fe548ec0..4aa74c8f 100644 --- a/tests/src/Drupal8/Rector/Deprecation/FunctionalTestDefaultThemePropertyRector/config/configured_rule.php +++ b/tests/src/Drupal8/Rector/Deprecation/FunctionalTestDefaultThemePropertyRector/config/configured_rule.php @@ -5,5 +5,5 @@ use Rector\Config\RectorConfig; return static function (RectorConfig $rectorConfig): void { - $rectorConfig->rule(\DrupalRector\Drupal8\Rector\Deprecation\FunctionalTestDefaultThemePropertyRector::class); + $rectorConfig->rule(DrupalRector\Drupal8\Rector\Deprecation\FunctionalTestDefaultThemePropertyRector::class); }; diff --git a/tests/src/Drupal9/Rector/Property/ProtectedStaticModulesPropertyRector/config/configured_rule.php b/tests/src/Drupal9/Rector/Property/ProtectedStaticModulesPropertyRector/config/configured_rule.php index 58043016..d424bb27 100644 --- a/tests/src/Drupal9/Rector/Property/ProtectedStaticModulesPropertyRector/config/configured_rule.php +++ b/tests/src/Drupal9/Rector/Property/ProtectedStaticModulesPropertyRector/config/configured_rule.php @@ -5,5 +5,5 @@ use Rector\Config\RectorConfig; return static function (RectorConfig $rectorConfig): void { - $rectorConfig->rule(\DrupalRector\Drupal9\Rector\Property\ProtectedStaticModulesPropertyRector::class); + $rectorConfig->rule(DrupalRector\Drupal9\Rector\Property\ProtectedStaticModulesPropertyRector::class); }; From a1d3069f1ccccbad694fef28adc38e9cd2725c93 Mon Sep 17 00:00:00 2001 From: bjorn Date: Thu, 11 Jan 2024 09:56:36 +0100 Subject: [PATCH 13/18] Don't fail fast so we know what versions pass in matrix --- .github/workflows/functional_test__rector_examples.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/functional_test__rector_examples.yml b/.github/workflows/functional_test__rector_examples.yml index 18f97385..2402ecf3 100644 --- a/.github/workflows/functional_test__rector_examples.yml +++ b/.github/workflows/functional_test__rector_examples.yml @@ -15,6 +15,7 @@ jobs: run_functional_test: name: Functional Test | PHP ${{ matrix.php-version }} | Drupal ${{ matrix.drupal }}" strategy: + fail-fast: false matrix: include: - php-version: "7.4" From 806fdeab1a4d3fd4e4a16ec4011d0befee1b282d Mon Sep 17 00:00:00 2001 From: bjorn Date: Thu, 11 Jan 2024 10:00:47 +0100 Subject: [PATCH 14/18] Try with consitional logic --- src/Drupal8/Rector/Deprecation/EntityLoadRector.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/Drupal8/Rector/Deprecation/EntityLoadRector.php b/src/Drupal8/Rector/Deprecation/EntityLoadRector.php index 3e7dd9e9..df66c3c9 100644 --- a/src/Drupal8/Rector/Deprecation/EntityLoadRector.php +++ b/src/Drupal8/Rector/Deprecation/EntityLoadRector.php @@ -169,11 +169,19 @@ public function refactor(Node $node): ?Node $resetCache_method_name = new Node\Identifier('resetCache'); + + if (!class_exists('\PhpParser\Node\ArrayItem')) { + $arrayItems = [new Node\Expr\ArrayItem($entity_id->value)]; + } else { + $arrayItems = [new \PhpParser\Node\ArrayItem($entity_id->value)]; + } + $reset_args = [ // This creates a new argument that wraps the entity ID in an array. - new Node\Arg(new Node\Expr\Array_([new \PhpParser\Node\ArrayItem($entity_id->value)])), + new Node\Arg(new Node\Expr\Array_($arrayItems)), ]; + $entity_load_reset_node = new Node\Expr\MethodCall($getStorage_node, $resetCache_method_name, $reset_args); From 4f67d28543ec6f0538cf078550467c9ff9cd96a7 Mon Sep 17 00:00:00 2001 From: DDEV User Date: Thu, 11 Jan 2024 09:01:55 +0000 Subject: [PATCH 15/18] fix style --- src/Drupal8/Rector/Deprecation/EntityLoadRector.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/Drupal8/Rector/Deprecation/EntityLoadRector.php b/src/Drupal8/Rector/Deprecation/EntityLoadRector.php index df66c3c9..66e9bcc2 100644 --- a/src/Drupal8/Rector/Deprecation/EntityLoadRector.php +++ b/src/Drupal8/Rector/Deprecation/EntityLoadRector.php @@ -169,7 +169,6 @@ public function refactor(Node $node): ?Node $resetCache_method_name = new Node\Identifier('resetCache'); - if (!class_exists('\PhpParser\Node\ArrayItem')) { $arrayItems = [new Node\Expr\ArrayItem($entity_id->value)]; } else { @@ -181,7 +180,6 @@ public function refactor(Node $node): ?Node new Node\Arg(new Node\Expr\Array_($arrayItems)), ]; - $entity_load_reset_node = new Node\Expr\MethodCall($getStorage_node, $resetCache_method_name, $reset_args); From d0e6f0d5dd8b04876fa08c8b119e12e66d99e6a1 Mon Sep 17 00:00:00 2001 From: Timo Huisman Date: Thu, 11 Jan 2024 10:18:38 +0100 Subject: [PATCH 16/18] feat: add rector rule for format_size in 10.2 --- .../drupal-10/drupal-10-all-deprecations.php | 1 + config/drupal-10/drupal-10.2-deprecations.php | 19 +++++++++++++++++++ src/Set/Drupal10SetList.php | 1 + stubs/Drupal/Drupal.php | 2 +- .../config/configured_rule.php | 1 + .../fixture/function_to_static_call.php.inc | 8 ++++++++ 6 files changed, 31 insertions(+), 1 deletion(-) create mode 100644 config/drupal-10/drupal-10.2-deprecations.php diff --git a/config/drupal-10/drupal-10-all-deprecations.php b/config/drupal-10/drupal-10-all-deprecations.php index d7667917..43cbdd84 100644 --- a/config/drupal-10/drupal-10-all-deprecations.php +++ b/config/drupal-10/drupal-10-all-deprecations.php @@ -9,6 +9,7 @@ $rectorConfig->sets([ Drupal10SetList::DRUPAL_100, Drupal10SetList::DRUPAL_101, + Drupal10SetList::DRUPAL_102, ]); $rectorConfig->bootstrapFiles([ diff --git a/config/drupal-10/drupal-10.2-deprecations.php b/config/drupal-10/drupal-10.2-deprecations.php new file mode 100644 index 00000000..93953287 --- /dev/null +++ b/config/drupal-10/drupal-10.2-deprecations.php @@ -0,0 +1,19 @@ +sets([ + SymfonyLevelSetList::UP_TO_SYMFONY_63, + ]); + + // https://www.drupal.org/node/2999981 + $rectorConfig->ruleWithConfiguration(FunctionToStaticRector::class, [ + new FunctionToStaticConfiguration('10.2.0', 'format_size', '\Drupal\Core\StringTranslation\ByteSizeMarkup', 'create'), + ]); +}; diff --git a/src/Set/Drupal10SetList.php b/src/Set/Drupal10SetList.php index aafeb6e5..768e2eba 100644 --- a/src/Set/Drupal10SetList.php +++ b/src/Set/Drupal10SetList.php @@ -11,4 +11,5 @@ final class Drupal10SetList implements SetListInterface public const DRUPAL_10 = __DIR__.'/../../config/drupal-10/drupal-10-all-deprecations.php'; public const DRUPAL_100 = __DIR__.'/../../config/drupal-10/drupal-10.0-deprecations.php'; public const DRUPAL_101 = __DIR__.'/../../config/drupal-10/drupal-10.1-deprecations.php'; + public const DRUPAL_102 = __DIR__.'/../../config/drupal-10/drupal-10.2-deprecations.php'; } diff --git a/stubs/Drupal/Drupal.php b/stubs/Drupal/Drupal.php index a6f3f522..3746b919 100644 --- a/stubs/Drupal/Drupal.php +++ b/stubs/Drupal/Drupal.php @@ -5,5 +5,5 @@ } class Drupal { - const VERSION = '10.1.x-dev'; + const VERSION = '10.2.x-dev'; } diff --git a/tests/src/Rector/Deprecation/FunctionToStaticRector/config/configured_rule.php b/tests/src/Rector/Deprecation/FunctionToStaticRector/config/configured_rule.php index 0013a28f..eba3a534 100644 --- a/tests/src/Rector/Deprecation/FunctionToStaticRector/config/configured_rule.php +++ b/tests/src/Rector/Deprecation/FunctionToStaticRector/config/configured_rule.php @@ -11,5 +11,6 @@ DeprecationBase::addClass(FunctionToStaticRector::class, $rectorConfig, false, [ new FunctionToStaticConfiguration('8.1.0', 'file_directory_os_temp', 'Drupal\Component\FileSystem\FileSystem', 'getOsTemporaryDirectory'), new FunctionToStaticConfiguration('10.1.0', 'drupal_rewrite_settings', 'Drupal\Core\Site\SettingsEditor', 'rewrite', [0 => 1, 1 => 0]), + new FunctionToStaticConfiguration('10.2.0', 'format_size', '\Drupal\Core\StringTranslation\ByteSizeMarkup', 'create'), ]); }; diff --git a/tests/src/Rector/Deprecation/FunctionToStaticRector/fixture/function_to_static_call.php.inc b/tests/src/Rector/Deprecation/FunctionToStaticRector/fixture/function_to_static_call.php.inc index d51f9f41..b6baaf92 100644 --- a/tests/src/Rector/Deprecation/FunctionToStaticRector/fixture/function_to_static_call.php.inc +++ b/tests/src/Rector/Deprecation/FunctionToStaticRector/fixture/function_to_static_call.php.inc @@ -12,6 +12,10 @@ function simple_example() { function simple_example_os_temp() { $x = file_directory_os_temp(); } + +function simple_example_format_size() { + $size_literal = format_size(81862076662); +} ?> ----- format_size(81862076662), fn() => \\Drupal\Core\StringTranslation\ByteSizeMarkup::create(81862076662)); +} ?> From aa11559a77bda0331d9d331345e1209e3ab234c4 Mon Sep 17 00:00:00 2001 From: Timo Huisman Date: Thu, 11 Jan 2024 19:58:42 +0100 Subject: [PATCH 17/18] refactor: remove duplicated SymfonyLevelSetList --- config/drupal-10/drupal-10.2-deprecations.php | 5 ----- 1 file changed, 5 deletions(-) diff --git a/config/drupal-10/drupal-10.2-deprecations.php b/config/drupal-10/drupal-10.2-deprecations.php index 93953287..e7c3122c 100644 --- a/config/drupal-10/drupal-10.2-deprecations.php +++ b/config/drupal-10/drupal-10.2-deprecations.php @@ -5,13 +5,8 @@ use DrupalRector\Rector\Deprecation\FunctionToStaticRector; use DrupalRector\Rector\ValueObject\FunctionToStaticConfiguration; use Rector\Config\RectorConfig; -use Rector\Symfony\Set\SymfonyLevelSetList; return static function (RectorConfig $rectorConfig): void { - $rectorConfig->sets([ - SymfonyLevelSetList::UP_TO_SYMFONY_63, - ]); - // https://www.drupal.org/node/2999981 $rectorConfig->ruleWithConfiguration(FunctionToStaticRector::class, [ new FunctionToStaticConfiguration('10.2.0', 'format_size', '\Drupal\Core\StringTranslation\ByteSizeMarkup', 'create'), From 0617aa123f17002a65eb162590a9af93c0422892 Mon Sep 17 00:00:00 2001 From: Timo Huisman Date: Fri, 12 Jan 2024 10:21:58 +0100 Subject: [PATCH 18/18] bugfix: switch arguments of AbstractDrupalCoreRector --- docs/rules_overview.md | 6 +++--- .../function_to_static_call.php | 2 +- src/Rector/AbstractDrupalCoreRector.php | 2 +- .../Deprecation/DeprecationHelperRemoveRector.php | 10 +++++----- .../fixture/system_time_zones.php.inc | 8 ++++---- .../fixture/watchdog_exception.php.inc | 6 +++--- .../fixture/user_password.php.inc | 6 +++--- .../fixture/user_password_keep.php.inc | 12 ++++++------ .../fixture/function_to_static_call.php.inc | 4 ++-- 9 files changed, 28 insertions(+), 28 deletions(-) diff --git a/docs/rules_overview.md b/docs/rules_overview.md index f6580895..c6d108cd 100644 --- a/docs/rules_overview.md +++ b/docs/rules_overview.md @@ -869,10 +869,10 @@ Remove DeprecationHelper calls for versions before configured minimum requiremen ```diff $settings = []; $filename = 'simple_filename.yaml'; --DeprecationHelper::backwardsCompatibleCall(\Drupal::VERSION, '9.1.0', fn() => old_function(), fn() => new_function()); --DeprecationHelper::backwardsCompatibleCall(\Drupal::VERSION, '10.5.0', fn() => drupal_rewrite_settings($settings, $filename), fn() => SettingsEditor::rewrite($filename, $settings)); +-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)); +drupal_rewrite_settings($settings, $filename); - DeprecationHelper::backwardsCompatibleCall(\Drupal::VERSION, '11.1.0', fn() => old_function(), fn() => new_function()); + DeprecationHelper::backwardsCompatibleCall(\Drupal::VERSION, '11.1.0', fn() => new_function(), fn() => old_function()); ```
diff --git a/fixtures/d10/rector_examples_updated/function_to_static_call.php b/fixtures/d10/rector_examples_updated/function_to_static_call.php index 6e316785..91a260ae 100644 --- a/fixtures/d10/rector_examples_updated/function_to_static_call.php +++ b/fixtures/d10/rector_examples_updated/function_to_static_call.php @@ -5,5 +5,5 @@ function simple_example() { $settings = []; $filename = 'simple_filename.yaml'; - DeprecationHelper::backwardsCompatibleCall(\Drupal::VERSION, '10.1.0', fn() => drupal_rewrite_settings($settings, $filename), fn() => SettingsEditor::rewrite($filename, $settings)); + DeprecationHelper::backwardsCompatibleCall(\Drupal::VERSION, '10.1.0', fn() => SettingsEditor::rewrite($filename, $settings), fn() => drupal_rewrite_settings($settings, $filename)); } diff --git a/src/Rector/AbstractDrupalCoreRector.php b/src/Rector/AbstractDrupalCoreRector.php index d95f1205..d44e0b7b 100644 --- a/src/Rector/AbstractDrupalCoreRector.php +++ b/src/Rector/AbstractDrupalCoreRector.php @@ -80,8 +80,8 @@ private function createBcCallOnCallLike(Node\Expr\CallLike $node, Node\Expr\Call return $this->nodeFactory->createStaticCall(DeprecationHelper::class, 'backwardsCompatibleCall', [ $this->nodeFactory->createClassConstFetch(\Drupal::class, 'VERSION'), $introducedVersion, - new ArrowFunction(['expr' => $clonedNode]), new ArrowFunction(['expr' => $result]), + new ArrowFunction(['expr' => $clonedNode]), ]); } } diff --git a/src/Rector/Deprecation/DeprecationHelperRemoveRector.php b/src/Rector/Deprecation/DeprecationHelperRemoveRector.php index 2cc66505..634c6857 100644 --- a/src/Rector/Deprecation/DeprecationHelperRemoveRector.php +++ b/src/Rector/Deprecation/DeprecationHelperRemoveRector.php @@ -28,16 +28,16 @@ public function getRuleDefinition(): RuleDefinition <<<'CODE_BEFORE' $settings = []; $filename = 'simple_filename.yaml'; -DeprecationHelper::backwardsCompatibleCall(\Drupal::VERSION, '9.1.0', fn() => old_function(), fn() => new_function()); -DeprecationHelper::backwardsCompatibleCall(\Drupal::VERSION, '10.5.0', fn() => drupal_rewrite_settings($settings, $filename), fn() => SettingsEditor::rewrite($filename, $settings)); -DeprecationHelper::backwardsCompatibleCall(\Drupal::VERSION, '11.1.0', fn() => old_function(), fn() => new_function()); +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_AFTER' $settings = []; $filename = 'simple_filename.yaml'; drupal_rewrite_settings($settings, $filename); -DeprecationHelper::backwardsCompatibleCall(\Drupal::VERSION, '11.1.0', fn() => old_function(), fn() => new_function()); +DeprecationHelper::backwardsCompatibleCall(\Drupal::VERSION, '11.1.0', fn() => new_function(), fn() => old_function()); CODE_AFTER , [ @@ -88,7 +88,7 @@ public function refactor(Node $node): ?Node continue; } - $newCall = $args[3]->value; + $newCall = $args[2]->value; if ($newCall instanceof Node\Expr\ArrowFunction) { return $newCall->expr; } diff --git a/tests/src/Drupal10/Rector/Deprecation/SystemTimeZonesRector/fixture/system_time_zones.php.inc b/tests/src/Drupal10/Rector/Deprecation/SystemTimeZonesRector/fixture/system_time_zones.php.inc index 09f79684..ca8669f4 100644 --- a/tests/src/Drupal10/Rector/Deprecation/SystemTimeZonesRector/fixture/system_time_zones.php.inc +++ b/tests/src/Drupal10/Rector/Deprecation/SystemTimeZonesRector/fixture/system_time_zones.php.inc @@ -15,12 +15,12 @@ function simple_example() { system_time_zones(), fn() => \Drupal\Core\Datetime\TimeZoneFormHelper::getOptionsList()); + \Drupal\Component\Utility\DeprecationHelper::backwardsCompatibleCall(\Drupal::VERSION, '10.1.0', fn() => \Drupal\Core\Datetime\TimeZoneFormHelper::getOptionsList(), fn() => system_time_zones()); - \Drupal\Component\Utility\DeprecationHelper::backwardsCompatibleCall(\Drupal::VERSION, '10.1.0', fn() => system_time_zones(FALSE, TRUE), fn() => \Drupal\Core\Datetime\TimeZoneFormHelper::getOptionsListByRegion()); + \Drupal\Component\Utility\DeprecationHelper::backwardsCompatibleCall(\Drupal::VERSION, '10.1.0', fn() => \Drupal\Core\Datetime\TimeZoneFormHelper::getOptionsListByRegion(), fn() => system_time_zones(FALSE, TRUE)); - \Drupal\Component\Utility\DeprecationHelper::backwardsCompatibleCall(\Drupal::VERSION, '10.1.0', fn() => system_time_zones(NULL, FALSE), fn() => \Drupal\Core\Datetime\TimeZoneFormHelper::getOptionsList(NULL)); + \Drupal\Component\Utility\DeprecationHelper::backwardsCompatibleCall(\Drupal::VERSION, '10.1.0', fn() => \Drupal\Core\Datetime\TimeZoneFormHelper::getOptionsList(NULL), fn() => system_time_zones(NULL, FALSE)); - \Drupal\Component\Utility\DeprecationHelper::backwardsCompatibleCall(\Drupal::VERSION, '10.1.0', fn() => system_time_zones(TRUE, FALSE), fn() => \Drupal\Core\Datetime\TimeZoneFormHelper::getOptionsList(TRUE)); + \Drupal\Component\Utility\DeprecationHelper::backwardsCompatibleCall(\Drupal::VERSION, '10.1.0', fn() => \Drupal\Core\Datetime\TimeZoneFormHelper::getOptionsList(TRUE), fn() => system_time_zones(TRUE, FALSE)); } ?> diff --git a/tests/src/Drupal10/Rector/Deprecation/WatchdogExceptionRector/fixture/watchdog_exception.php.inc b/tests/src/Drupal10/Rector/Deprecation/WatchdogExceptionRector/fixture/watchdog_exception.php.inc index c61ede53..8d40c958 100644 --- a/tests/src/Drupal10/Rector/Deprecation/WatchdogExceptionRector/fixture/watchdog_exception.php.inc +++ b/tests/src/Drupal10/Rector/Deprecation/WatchdogExceptionRector/fixture/watchdog_exception.php.inc @@ -17,15 +17,15 @@ function advanced() { watchdog_exception('update', $exception), fn() => \Drupal\Core\Utility\Error::logException(\Drupal::logger('update'), $exception)); + \Drupal\Component\Utility\DeprecationHelper::backwardsCompatibleCall(\Drupal::VERSION, '10.1.0', fn() => \Drupal\Core\Utility\Error::logException(\Drupal::logger('update'), $exception), fn() => watchdog_exception('update', $exception)); } /** * A simple example. */ function advanced() { - \Drupal\Component\Utility\DeprecationHelper::backwardsCompatibleCall(\Drupal::VERSION, '10.1.0', fn() => watchdog_exception('update', $exception, 'My custom message @foo', ['@foo' => 'bar', 'link' => 'http://example.com'], RfcLogLevel::CRITICAL, 'http://example.com'), fn() => \Drupal\Core\Utility\Error::logException(\Drupal::logger('update'), $exception, 'My custom message @foo', ['@foo' => 'bar', 'link' => 'http://example.com'], RfcLogLevel::CRITICAL)); + \Drupal\Component\Utility\DeprecationHelper::backwardsCompatibleCall(\Drupal::VERSION, '10.1.0', fn() => \Drupal\Core\Utility\Error::logException(\Drupal::logger('update'), $exception, 'My custom message @foo', ['@foo' => 'bar', 'link' => 'http://example.com'], RfcLogLevel::CRITICAL), fn() => watchdog_exception('update', $exception, 'My custom message @foo', ['@foo' => 'bar', 'link' => 'http://example.com'], RfcLogLevel::CRITICAL, 'http://example.com')); - \Drupal\Component\Utility\DeprecationHelper::backwardsCompatibleCall(\Drupal::VERSION, '10.1.0', fn() => watchdog_exception('update', $exception, 'My custom message @foo', ['@foo' => 'bar']), fn() => \Drupal\Core\Utility\Error::logException(\Drupal::logger('update'), $exception, 'My custom message @foo', ['@foo' => 'bar'])); + \Drupal\Component\Utility\DeprecationHelper::backwardsCompatibleCall(\Drupal::VERSION, '10.1.0', fn() => \Drupal\Core\Utility\Error::logException(\Drupal::logger('update'), $exception, 'My custom message @foo', ['@foo' => 'bar']), fn() => watchdog_exception('update', $exception, 'My custom message @foo', ['@foo' => 'bar'])); } ?> diff --git a/tests/src/Rector/Deprecation/DeprecationHelperRemoveRector/fixture/user_password.php.inc b/tests/src/Rector/Deprecation/DeprecationHelperRemoveRector/fixture/user_password.php.inc index f557476e..29341a6a 100644 --- a/tests/src/Rector/Deprecation/DeprecationHelperRemoveRector/fixture/user_password.php.inc +++ b/tests/src/Rector/Deprecation/DeprecationHelperRemoveRector/fixture/user_password.php.inc @@ -2,10 +2,10 @@ function simple_example() { - $password = \Drupal\Component\Utility\DeprecationHelper::backwardsCompatibleCall(\Drupal::VERSION, '9.1.0', fn() => user_password(), fn() => \Drupal::service('password_generator')->generate()); - $other_password = \Drupal\Component\Utility\DeprecationHelper::backwardsCompatibleCall(\Drupal::VERSION, '9.1.0', fn() => user_password(8), fn() => \Drupal::service('password_generator')->generate(8)); + $password = \Drupal\Component\Utility\DeprecationHelper::backwardsCompatibleCall(\Drupal::VERSION, '9.1.0', fn() => \Drupal::service('password_generator')->generate(), fn() => user_password()); + $other_password = \Drupal\Component\Utility\DeprecationHelper::backwardsCompatibleCall(\Drupal::VERSION, '9.1.0', fn() => \Drupal::service('password_generator')->generate(8), fn() => user_password(8)); $password_length = 12; - $last_password = \Drupal\Component\Utility\DeprecationHelper::backwardsCompatibleCall(\Drupal::VERSION, '9.1.0', fn() => user_password($password_length), fn() => \Drupal::service('password_generator')->generate($password_length)); + $last_password = \Drupal\Component\Utility\DeprecationHelper::backwardsCompatibleCall(\Drupal::VERSION, '9.1.0', fn() => \Drupal::service('password_generator')->generate($password_length), fn() => user_password($password_length)); } ?> diff --git a/tests/src/Rector/Deprecation/DeprecationHelperRemoveRector/fixture/user_password_keep.php.inc b/tests/src/Rector/Deprecation/DeprecationHelperRemoveRector/fixture/user_password_keep.php.inc index cb71459d..da7e0faf 100644 --- a/tests/src/Rector/Deprecation/DeprecationHelperRemoveRector/fixture/user_password_keep.php.inc +++ b/tests/src/Rector/Deprecation/DeprecationHelperRemoveRector/fixture/user_password_keep.php.inc @@ -4,10 +4,10 @@ use Drupal\Component\Utility\DeprecationHelper; function simple_example() { - $password = DeprecationHelper::backwardsCompatibleCall(\Drupal::VERSION, '10.5.0', fn() => user_password(), fn() => \Drupal::service('password_generator')->generate()); - $other_password = DeprecationHelper::backwardsCompatibleCall(\Drupal::VERSION, '10.5.0', fn() => user_password(8), fn() => \Drupal::service('password_generator')->generate(8)); + $password = DeprecationHelper::backwardsCompatibleCall(\Drupal::VERSION, '10.5.0', fn() => \Drupal::service('password_generator')->generate(), fn() => user_password()); + $other_password = DeprecationHelper::backwardsCompatibleCall(\Drupal::VERSION, '10.5.0', fn() => \Drupal::service('password_generator')->generate(8), fn() => user_password(8)); $password_length = 12; - $last_password = DeprecationHelper::backwardsCompatibleCall(\Drupal::VERSION, '10.5.0', fn() => user_password($password_length), fn() => \Drupal::service('password_generator')->generate($password_length)); + $last_password = DeprecationHelper::backwardsCompatibleCall(\Drupal::VERSION, '10.5.0', fn() => \Drupal::service('password_generator')->generate($password_length), fn() => user_password($password_length)); } ?> @@ -18,10 +18,10 @@ use Drupal\Component\Utility\DeprecationHelper; function simple_example() { - $password = DeprecationHelper::backwardsCompatibleCall(\Drupal::VERSION, '10.5.0', fn() => user_password(), fn() => \Drupal::service('password_generator')->generate()); - $other_password = DeprecationHelper::backwardsCompatibleCall(\Drupal::VERSION, '10.5.0', fn() => user_password(8), fn() => \Drupal::service('password_generator')->generate(8)); + $password = DeprecationHelper::backwardsCompatibleCall(\Drupal::VERSION, '10.5.0', fn() => \Drupal::service('password_generator')->generate(), fn() => user_password()); + $other_password = DeprecationHelper::backwardsCompatibleCall(\Drupal::VERSION, '10.5.0', fn() => \Drupal::service('password_generator')->generate(8), fn() => user_password(8)); $password_length = 12; - $last_password = DeprecationHelper::backwardsCompatibleCall(\Drupal::VERSION, '10.5.0', fn() => user_password($password_length), fn() => \Drupal::service('password_generator')->generate($password_length)); + $last_password = DeprecationHelper::backwardsCompatibleCall(\Drupal::VERSION, '10.5.0', fn() => \Drupal::service('password_generator')->generate($password_length), fn() => user_password($password_length)); } ?> diff --git a/tests/src/Rector/Deprecation/FunctionToStaticRector/fixture/function_to_static_call.php.inc b/tests/src/Rector/Deprecation/FunctionToStaticRector/fixture/function_to_static_call.php.inc index b6baaf92..2f2d5767 100644 --- a/tests/src/Rector/Deprecation/FunctionToStaticRector/fixture/function_to_static_call.php.inc +++ b/tests/src/Rector/Deprecation/FunctionToStaticRector/fixture/function_to_static_call.php.inc @@ -23,7 +23,7 @@ function simple_example_format_size() { function simple_example() { $settings = []; $filename = 'simple_filename.yaml'; - \Drupal\Component\Utility\DeprecationHelper::backwardsCompatibleCall(\Drupal::VERSION, '10.1.0', fn() => drupal_rewrite_settings($settings, $filename), fn() => \Drupal\Core\Site\SettingsEditor::rewrite($filename, $settings)); + \Drupal\Component\Utility\DeprecationHelper::backwardsCompatibleCall(\Drupal::VERSION, '10.1.0', fn() => \Drupal\Core\Site\SettingsEditor::rewrite($filename, $settings), fn() => drupal_rewrite_settings($settings, $filename)); } /** @@ -34,6 +34,6 @@ function simple_example_os_temp() { } function simple_example_format_size() { - $size_literal = \Drupal\Component\Utility\DeprecationHelper::backwardsCompatibleCall(\Drupal::VERSION, '10.2.0', fn() => format_size(81862076662), fn() => \\Drupal\Core\StringTranslation\ByteSizeMarkup::create(81862076662)); + $size_literal = \Drupal\Component\Utility\DeprecationHelper::backwardsCompatibleCall(\Drupal::VERSION, '10.2.0', fn() => \\Drupal\Core\StringTranslation\ByteSizeMarkup::create(81862076662), fn() => format_size(81862076662)); } ?>