From b3b823c3d41ab4b238dd7473dd4dcc9cbdc2ea6b Mon Sep 17 00:00:00 2001 From: bjorn Date: Fri, 24 Jan 2025 10:20:52 +0100 Subject: [PATCH 1/6] fix: remove deprecated SetInterface --- phpstan-baseline.neon | 24 ------------------------ src/Set/Drupal10SetList.php | 4 +--- src/Set/Drupal8SetList.php | 4 +--- src/Set/Drupal9SetList.php | 4 +--- 4 files changed, 3 insertions(+), 33 deletions(-) diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index 38ca9036..8cb19a04 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -155,27 +155,3 @@ parameters: """ count: 1 path: src/Drupal9/Rector/Deprecation/PassRector.php - - - - message: """ - #^Class DrupalRector\\\\Set\\\\Drupal10SetList implements deprecated interface Rector\\\\Set\\\\Contract\\\\SetListInterface\\: - This interface needs a reflection to load and uses constant links\\. Now we changed to services provider architecture that can be used and registerd easily\\. Use$# - """ - count: 1 - path: src/Set/Drupal10SetList.php - - - - message: """ - #^Class DrupalRector\\\\Set\\\\Drupal8SetList implements deprecated interface Rector\\\\Set\\\\Contract\\\\SetListInterface\\: - This interface needs a reflection to load and uses constant links\\. Now we changed to services provider architecture that can be used and registerd easily\\. Use$# - """ - count: 1 - path: src/Set/Drupal8SetList.php - - - - message: """ - #^Class DrupalRector\\\\Set\\\\Drupal9SetList implements deprecated interface Rector\\\\Set\\\\Contract\\\\SetListInterface\\: - This interface needs a reflection to load and uses constant links\\. Now we changed to services provider architecture that can be used and registerd easily\\. Use$# - """ - count: 1 - path: src/Set/Drupal9SetList.php diff --git a/src/Set/Drupal10SetList.php b/src/Set/Drupal10SetList.php index 724dd993..c0829218 100644 --- a/src/Set/Drupal10SetList.php +++ b/src/Set/Drupal10SetList.php @@ -4,9 +4,7 @@ namespace DrupalRector\Set; -use Rector\Set\Contract\SetListInterface; - -final class Drupal10SetList implements SetListInterface +final class Drupal10SetList { 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'; diff --git a/src/Set/Drupal8SetList.php b/src/Set/Drupal8SetList.php index 17ced2b9..810190b7 100644 --- a/src/Set/Drupal8SetList.php +++ b/src/Set/Drupal8SetList.php @@ -4,9 +4,7 @@ namespace DrupalRector\Set; -use Rector\Set\Contract\SetListInterface; - -final class Drupal8SetList implements SetListInterface +final class Drupal8SetList { public const DRUPAL_8 = __DIR__.'/../../config/drupal-8/drupal-8-all-deprecations.php'; public const DRUPAL_80 = __DIR__.'/../../config/drupal-8/drupal-8.0-deprecations.php'; diff --git a/src/Set/Drupal9SetList.php b/src/Set/Drupal9SetList.php index 1141640f..b6397ec9 100644 --- a/src/Set/Drupal9SetList.php +++ b/src/Set/Drupal9SetList.php @@ -4,9 +4,7 @@ namespace DrupalRector\Set; -use Rector\Set\Contract\SetListInterface; - -final class Drupal9SetList implements SetListInterface +final class Drupal9SetList { public const DRUPAL_9 = __DIR__.'/../../config/drupal-9/drupal-9-all-deprecations.php'; public const DRUPAL_90 = __DIR__.'/../../config/drupal-9/drupal-9.0-deprecations.php'; From 6afdd39e340c80e169b87322a3a185b13a2ae5ad Mon Sep 17 00:00:00 2001 From: bjorn Date: Fri, 24 Jan 2025 10:23:39 +0100 Subject: [PATCH 2/6] build: fix codestyle --- src/Drupal8/Rector/Deprecation/DBRector.php | 2 +- src/Drupal8/Rector/Deprecation/DrupalServiceRenameRector.php | 2 +- src/Drupal8/Rector/Deprecation/EntityLoadRector.php | 2 +- src/Drupal9/Rector/Deprecation/ExtensionPathRector.php | 2 +- .../Rector/Deprecation/UiHelperTraitDrupalPostFormRector.php | 2 +- src/Rector/AbstractDrupalCoreRector.php | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Drupal8/Rector/Deprecation/DBRector.php b/src/Drupal8/Rector/Deprecation/DBRector.php index 4963b5f7..d4c6df70 100644 --- a/src/Drupal8/Rector/Deprecation/DBRector.php +++ b/src/Drupal8/Rector/Deprecation/DBRector.php @@ -56,7 +56,7 @@ class DBRector extends AbstractRector implements ConfigurableRectorInterface protected $optionsArgumentPosition; /** - * @var \DrupalRector\Drupal8\Rector\ValueObject\DBConfiguration[] + * @var DBConfiguration[] */ private array $configuration; diff --git a/src/Drupal8/Rector/Deprecation/DrupalServiceRenameRector.php b/src/Drupal8/Rector/Deprecation/DrupalServiceRenameRector.php index 43726353..61b17330 100644 --- a/src/Drupal8/Rector/Deprecation/DrupalServiceRenameRector.php +++ b/src/Drupal8/Rector/Deprecation/DrupalServiceRenameRector.php @@ -14,7 +14,7 @@ class DrupalServiceRenameRector extends AbstractRector implements ConfigurableRectorInterface { /** - * @var \DrupalRector\Drupal8\Rector\ValueObject\DrupalServiceRenameConfiguration[] + * @var DrupalServiceRenameConfiguration[] */ protected array $staticArgumentRenameConfigs = []; diff --git a/src/Drupal8/Rector/Deprecation/EntityLoadRector.php b/src/Drupal8/Rector/Deprecation/EntityLoadRector.php index 7c3bb7fa..66b5e5b5 100644 --- a/src/Drupal8/Rector/Deprecation/EntityLoadRector.php +++ b/src/Drupal8/Rector/Deprecation/EntityLoadRector.php @@ -27,7 +27,7 @@ final class EntityLoadRector extends AbstractRector implements ConfigurableRectorInterface { /** - * @var \DrupalRector\Drupal8\Rector\ValueObject\EntityLoadConfiguration[] + * @var EntityLoadConfiguration[] */ protected array $entityTypes; diff --git a/src/Drupal9/Rector/Deprecation/ExtensionPathRector.php b/src/Drupal9/Rector/Deprecation/ExtensionPathRector.php index e0d9ca33..a8043d94 100644 --- a/src/Drupal9/Rector/Deprecation/ExtensionPathRector.php +++ b/src/Drupal9/Rector/Deprecation/ExtensionPathRector.php @@ -15,7 +15,7 @@ class ExtensionPathRector extends AbstractRector implements ConfigurableRectorInterface { /** - * @var \DrupalRector\Drupal9\Rector\ValueObject\ExtensionPathConfiguration[] + * @var ExtensionPathConfiguration[] */ private array $configuration; diff --git a/src/Drupal9/Rector/Deprecation/UiHelperTraitDrupalPostFormRector.php b/src/Drupal9/Rector/Deprecation/UiHelperTraitDrupalPostFormRector.php index 208f4ebf..9a3462ee 100644 --- a/src/Drupal9/Rector/Deprecation/UiHelperTraitDrupalPostFormRector.php +++ b/src/Drupal9/Rector/Deprecation/UiHelperTraitDrupalPostFormRector.php @@ -48,7 +48,7 @@ public function getNodeTypes(): array * * @throws ShouldNotHappenException * - * @return array + * @return array */ private function safeArgDestructure(Node\Expr\MethodCall $node): array { diff --git a/src/Rector/AbstractDrupalCoreRector.php b/src/Rector/AbstractDrupalCoreRector.php index 89ac7c5b..8edfb174 100644 --- a/src/Rector/AbstractDrupalCoreRector.php +++ b/src/Rector/AbstractDrupalCoreRector.php @@ -16,7 +16,7 @@ abstract class AbstractDrupalCoreRector extends AbstractRector implements ConfigurableRectorInterface { /** - * @var array|\DrupalRector\Contract\VersionedConfigurationInterface[] + * @var array|VersionedConfigurationInterface[] */ protected array $configuration = []; From daf34966a93686719df945dcbbc8677834bc31e4 Mon Sep 17 00:00:00 2001 From: bjorn Date: Fri, 24 Jan 2025 10:33:52 +0100 Subject: [PATCH 3/6] fix: REMOVE_NODE constant has moved --- phpstan-baseline.neon | 8 -------- src/Drupal9/Rector/Deprecation/PassRector.php | 4 ++-- 2 files changed, 2 insertions(+), 10 deletions(-) diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index 8cb19a04..266ed64c 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -147,11 +147,3 @@ 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 diff --git a/src/Drupal9/Rector/Deprecation/PassRector.php b/src/Drupal9/Rector/Deprecation/PassRector.php index 60b68900..94a3dd12 100644 --- a/src/Drupal9/Rector/Deprecation/PassRector.php +++ b/src/Drupal9/Rector/Deprecation/PassRector.php @@ -6,7 +6,7 @@ use DrupalRector\Utility\GetDeclaringSourceTrait; use PhpParser\Node; -use PhpParser\NodeTraverser; +use PhpParser\NodeVisitor; use Rector\Rector\AbstractRector; use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; @@ -51,7 +51,7 @@ public function refactor(Node $node) } if ($this->getDeclaringSource($node->expr) === 'Drupal\KernelTests\AssertLegacyTrait') { - return NodeTraverser::REMOVE_NODE; + return NodeVisitor::REMOVE_NODE; } return $node; From 3ad8fc8b7d6b399335f22550dab6606a607a7284 Mon Sep 17 00:00:00 2001 From: bjorn Date: Fri, 24 Jan 2025 10:59:02 +0100 Subject: [PATCH 4/6] fix: fix unit tests with check for consstant --- src/Drupal9/Rector/Deprecation/PassRector.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/Drupal9/Rector/Deprecation/PassRector.php b/src/Drupal9/Rector/Deprecation/PassRector.php index 94a3dd12..3138163c 100644 --- a/src/Drupal9/Rector/Deprecation/PassRector.php +++ b/src/Drupal9/Rector/Deprecation/PassRector.php @@ -6,6 +6,7 @@ use DrupalRector\Utility\GetDeclaringSourceTrait; use PhpParser\Node; +use PhpParser\NodeTraverser; use PhpParser\NodeVisitor; use Rector\Rector\AbstractRector; use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; @@ -51,7 +52,12 @@ public function refactor(Node $node) } if ($this->getDeclaringSource($node->expr) === 'Drupal\KernelTests\AssertLegacyTrait') { - return NodeVisitor::REMOVE_NODE; + if (defined('\PhpParser\NodeVisitor::REMOVE_NODE')) { + return \PhpParser\NodeVisitor::REMOVE_NODE; + } else { + /** @@phpstan-ignore-next-line */ + return NodeTraverser::REMOVE_NODE; + } } return $node; From e965770f4429cbb7e54a1f4c8f23ff561942ce26 Mon Sep 17 00:00:00 2001 From: bjorn Date: Fri, 24 Jan 2025 13:22:04 +0100 Subject: [PATCH 5/6] build: fix codestyle for PassRector.php --- src/Drupal9/Rector/Deprecation/PassRector.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Drupal9/Rector/Deprecation/PassRector.php b/src/Drupal9/Rector/Deprecation/PassRector.php index 3138163c..e57df781 100644 --- a/src/Drupal9/Rector/Deprecation/PassRector.php +++ b/src/Drupal9/Rector/Deprecation/PassRector.php @@ -53,9 +53,9 @@ public function refactor(Node $node) if ($this->getDeclaringSource($node->expr) === 'Drupal\KernelTests\AssertLegacyTrait') { if (defined('\PhpParser\NodeVisitor::REMOVE_NODE')) { - return \PhpParser\NodeVisitor::REMOVE_NODE; + return NodeVisitor::REMOVE_NODE; } else { - /** @@phpstan-ignore-next-line */ + /* @@phpstan-ignore-next-line */ return NodeTraverser::REMOVE_NODE; } } From f66b2760c75a1b2175af0cdf4d76d4836b022369 Mon Sep 17 00:00:00 2001 From: bjorn Date: Fri, 24 Jan 2025 13:23:46 +0100 Subject: [PATCH 6/6] build: typo in phpstan ignore --- src/Drupal9/Rector/Deprecation/PassRector.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Drupal9/Rector/Deprecation/PassRector.php b/src/Drupal9/Rector/Deprecation/PassRector.php index e57df781..8e48d29a 100644 --- a/src/Drupal9/Rector/Deprecation/PassRector.php +++ b/src/Drupal9/Rector/Deprecation/PassRector.php @@ -55,7 +55,7 @@ public function refactor(Node $node) if (defined('\PhpParser\NodeVisitor::REMOVE_NODE')) { return NodeVisitor::REMOVE_NODE; } else { - /* @@phpstan-ignore-next-line */ + /* @phpstan-ignore-next-line */ return NodeTraverser::REMOVE_NODE; } }