From e10e9b86aeea1e4314db54c352254b8c103f94c8 Mon Sep 17 00:00:00 2001 From: bjorn Date: Sun, 31 Dec 2023 08:11:50 +0100 Subject: [PATCH] ConstantToClassConstantRector serves d8 and d9, it should be in the generic space --- config/drupal-8/drupal-8.5-deprecations.php | 4 +-- config/drupal-8/drupal-8.7-deprecations.php | 4 +-- config/drupal-9/drupal-9.3-deprecations.php | 4 +-- docs/rules_overview.md | 34 +++++++++---------- .../ConstantToClassConstantRector.php | 8 ++--- .../ConstantToClassConfiguration.php | 2 +- .../ConstantToClassConstantRectorTest.php | 2 +- .../config/configured_rule.php | 4 +-- .../fixture/fixture.php.inc | 0 9 files changed, 31 insertions(+), 31 deletions(-) rename src/{Drupal8 => }/Rector/Deprecation/ConstantToClassConstantRector.php (90%) rename src/{Drupal8 => }/Rector/ValueObject/ConstantToClassConfiguration.php (94%) rename tests/src/{Drupal8 => }/Rector/Deprecation/ConstantToClassConstantRector/ConstantToClassConstantRectorTest.php (90%) rename tests/src/{Drupal8 => }/Rector/Deprecation/ConstantToClassConstantRector/config/configured_rule.php (83%) rename tests/src/{Drupal8 => }/Rector/Deprecation/ConstantToClassConstantRector/fixture/fixture.php.inc (100%) diff --git a/config/drupal-8/drupal-8.5-deprecations.php b/config/drupal-8/drupal-8.5-deprecations.php index 64067b13..f0430179 100644 --- a/config/drupal-8/drupal-8.5-deprecations.php +++ b/config/drupal-8/drupal-8.5-deprecations.php @@ -2,9 +2,9 @@ declare(strict_types=1); -use DrupalRector\Drupal8\Rector\Deprecation\ConstantToClassConstantRector; use DrupalRector\Drupal8\Rector\Deprecation\DrupalSetMessageRector; -use DrupalRector\Drupal8\Rector\ValueObject\ConstantToClassConfiguration; +use DrupalRector\Rector\Deprecation\ConstantToClassConstantRector; +use DrupalRector\Rector\ValueObject\ConstantToClassConfiguration; use DrupalRector\Services\AddCommentService; use Rector\Config\RectorConfig; diff --git a/config/drupal-8/drupal-8.7-deprecations.php b/config/drupal-8/drupal-8.7-deprecations.php index 678e8b30..e21f5eda 100644 --- a/config/drupal-8/drupal-8.7-deprecations.php +++ b/config/drupal-8/drupal-8.7-deprecations.php @@ -2,9 +2,9 @@ declare(strict_types=1); -use DrupalRector\Drupal8\Rector\Deprecation\ConstantToClassConstantRector; -use DrupalRector\Drupal8\Rector\ValueObject\ConstantToClassConfiguration; +use DrupalRector\Rector\Deprecation\ConstantToClassConstantRector; use DrupalRector\Rector\Deprecation\FunctionToServiceRector; +use DrupalRector\Rector\ValueObject\ConstantToClassConfiguration; use DrupalRector\Rector\ValueObject\FunctionToServiceConfiguration; use DrupalRector\Services\AddCommentService; use Rector\Config\RectorConfig; diff --git a/config/drupal-9/drupal-9.3-deprecations.php b/config/drupal-9/drupal-9.3-deprecations.php index 6b6166a3..f93b1445 100644 --- a/config/drupal-9/drupal-9.3-deprecations.php +++ b/config/drupal-9/drupal-9.3-deprecations.php @@ -2,8 +2,6 @@ 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; use DrupalRector\Drupal9\Rector\Deprecation\FunctionToEntityTypeStorageMethod; @@ -15,8 +13,10 @@ use DrupalRector\Drupal9\Rector\ValueObject\ExtensionPathConfiguration; use DrupalRector\Drupal9\Rector\ValueObject\FunctionToEntityTypeStorageConfiguration; use DrupalRector\Drupal9\Rector\ValueObject\FunctionToFirstArgMethodConfiguration; +use DrupalRector\Rector\Deprecation\ConstantToClassConstantRector; use DrupalRector\Rector\Deprecation\FunctionToServiceRector; use DrupalRector\Rector\Deprecation\FunctionToStaticRector; +use DrupalRector\Rector\ValueObject\ConstantToClassConfiguration; use DrupalRector\Rector\ValueObject\FunctionToServiceConfiguration; use DrupalRector\Rector\ValueObject\FunctionToStaticConfiguration; use DrupalRector\Services\AddCommentService; diff --git a/docs/rules_overview.md b/docs/rules_overview.md index c6d108cd..1a80073f 100644 --- a/docs/rules_overview.md +++ b/docs/rules_overview.md @@ -6,11 +6,11 @@ - [Drupal10](#drupal10) (2) -- [Drupal8](#drupal8) (19) +- [Drupal8](#drupal8) (18) - [Drupal9](#drupal9) (26) -- [DrupalRector](#drupalrector) (5) +- [DrupalRector](#drupalrector) (6)
@@ -56,21 +56,6 @@ Fixes deprecated watchdog_exception('update', `$exception)` calls ## Drupal8 -### ConstantToClassConstantRector - -Fixes deprecated contant use - -:wrench: **configure it!** - -- class: [`DrupalRector\Drupal8\Rector\Deprecation\ConstantToClassConstantRector`](../src/Drupal8/Rector/Deprecation/ConstantToClassConstantRector.php) - -```diff --$result = file_unmanaged_copy($source, $destination, DEPRECATED_CONSTANT); -+$result = file_unmanaged_copy($source, $destination, \Drupal\MyClass::CONSTANT); -``` - -
- ### DBRector Fixes deprecated `db_delete()` calls @@ -858,6 +843,21 @@ Fixes deprecated `user_password()` calls ## DrupalRector +### ConstantToClassConstantRector + +Fixes deprecated contant use, used in Drupal 8 and 9 deprecations + +:wrench: **configure it!** + +- class: [`DrupalRector\Rector\Deprecation\ConstantToClassConstantRector`](../src/Rector/Deprecation/ConstantToClassConstantRector.php) + +```diff +-$result = file_unmanaged_copy($source, $destination, DEPRECATED_CONSTANT); ++$result = file_unmanaged_copy($source, $destination, \Drupal\MyClass::CONSTANT); +``` + +
+ ### DeprecationHelperRemoveRector Remove DeprecationHelper calls for versions before configured minimum requirement diff --git a/src/Drupal8/Rector/Deprecation/ConstantToClassConstantRector.php b/src/Rector/Deprecation/ConstantToClassConstantRector.php similarity index 90% rename from src/Drupal8/Rector/Deprecation/ConstantToClassConstantRector.php rename to src/Rector/Deprecation/ConstantToClassConstantRector.php index 3ee74eb7..cb1cc7ae 100644 --- a/src/Drupal8/Rector/Deprecation/ConstantToClassConstantRector.php +++ b/src/Rector/Deprecation/ConstantToClassConstantRector.php @@ -2,9 +2,9 @@ declare(strict_types=1); -namespace DrupalRector\Drupal8\Rector\Deprecation; +namespace DrupalRector\Rector\Deprecation; -use DrupalRector\Drupal8\Rector\ValueObject\ConstantToClassConfiguration; +use DrupalRector\Rector\ValueObject\ConstantToClassConfiguration; use PhpParser\Node; use Rector\Contract\Rector\ConfigurableRectorInterface; use Rector\Rector\AbstractRector; @@ -20,7 +20,7 @@ class ConstantToClassConstantRector extends AbstractRector implements ConfigurableRectorInterface { /** - * @var \DrupalRector\Drupal8\Rector\ValueObject\ConstantToClassConfiguration[] + * @var ConstantToClassConfiguration[] */ private array $constantToClassRenames; @@ -40,7 +40,7 @@ public function configure(array $configuration): void */ public function getRuleDefinition(): RuleDefinition { - return new RuleDefinition('Fixes deprecated contant use', [ + return new RuleDefinition('Fixes deprecated contant use, used in Drupal 8 and 9 deprecations', [ new ConfiguredCodeSample( <<<'CODE_BEFORE' $result = file_unmanaged_copy($source, $destination, DEPRECATED_CONSTANT); diff --git a/src/Drupal8/Rector/ValueObject/ConstantToClassConfiguration.php b/src/Rector/ValueObject/ConstantToClassConfiguration.php similarity index 94% rename from src/Drupal8/Rector/ValueObject/ConstantToClassConfiguration.php rename to src/Rector/ValueObject/ConstantToClassConfiguration.php index b8bfe544..98a5c16d 100644 --- a/src/Drupal8/Rector/ValueObject/ConstantToClassConfiguration.php +++ b/src/Rector/ValueObject/ConstantToClassConfiguration.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace DrupalRector\Drupal8\Rector\ValueObject; +namespace DrupalRector\Rector\ValueObject; use Rector\Validation\RectorAssert; diff --git a/tests/src/Drupal8/Rector/Deprecation/ConstantToClassConstantRector/ConstantToClassConstantRectorTest.php b/tests/src/Rector/Deprecation/ConstantToClassConstantRector/ConstantToClassConstantRectorTest.php similarity index 90% rename from tests/src/Drupal8/Rector/Deprecation/ConstantToClassConstantRector/ConstantToClassConstantRectorTest.php rename to tests/src/Rector/Deprecation/ConstantToClassConstantRector/ConstantToClassConstantRectorTest.php index e15349ad..b7698b1e 100644 --- a/tests/src/Drupal8/Rector/Deprecation/ConstantToClassConstantRector/ConstantToClassConstantRectorTest.php +++ b/tests/src/Rector/Deprecation/ConstantToClassConstantRector/ConstantToClassConstantRectorTest.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Drupal8\Rector\Deprecation\ConstantToClassConstantRector; +namespace DrupalRector\Rector\Deprecation\ConstantToClassConstantRector; use Iterator; use Rector\Testing\PHPUnit\AbstractRectorTestCase; diff --git a/tests/src/Drupal8/Rector/Deprecation/ConstantToClassConstantRector/config/configured_rule.php b/tests/src/Rector/Deprecation/ConstantToClassConstantRector/config/configured_rule.php similarity index 83% rename from tests/src/Drupal8/Rector/Deprecation/ConstantToClassConstantRector/config/configured_rule.php rename to tests/src/Rector/Deprecation/ConstantToClassConstantRector/config/configured_rule.php index aeec0664..fe541df3 100644 --- a/tests/src/Drupal8/Rector/Deprecation/ConstantToClassConstantRector/config/configured_rule.php +++ b/tests/src/Rector/Deprecation/ConstantToClassConstantRector/config/configured_rule.php @@ -2,8 +2,8 @@ declare(strict_types=1); -use DrupalRector\Drupal8\Rector\Deprecation\ConstantToClassConstantRector; -use DrupalRector\Drupal8\Rector\ValueObject\ConstantToClassConfiguration; +use DrupalRector\Rector\Deprecation\ConstantToClassConstantRector; +use DrupalRector\Rector\ValueObject\ConstantToClassConfiguration; use DrupalRector\Tests\Rector\Deprecation\DeprecationBase; use Rector\Config\RectorConfig; diff --git a/tests/src/Drupal8/Rector/Deprecation/ConstantToClassConstantRector/fixture/fixture.php.inc b/tests/src/Rector/Deprecation/ConstantToClassConstantRector/fixture/fixture.php.inc similarity index 100% rename from tests/src/Drupal8/Rector/Deprecation/ConstantToClassConstantRector/fixture/fixture.php.inc rename to tests/src/Rector/Deprecation/ConstantToClassConstantRector/fixture/fixture.php.inc