From bf6900b75a078a7ed60dc7170662be9233e75f80 Mon Sep 17 00:00:00 2001 From: Lee Rowlands <lee.rowlands@previousnext.com.au> Date: Thu, 19 Dec 2024 09:23:55 +1000 Subject: [PATCH] Issue #3352916 by spokje, mondrake, longwave, vladimiraus: Fix PHPStan L1 errors "Call to method getDefinitions()/getSortedDefinitions() on an unknown class Drupal\Core\Plugin\CategorizingPluginManagerTrait." --- core/.phpstan-baseline.php | 58 +------------------ .../Plugin/CategorizingPluginManagerTrait.php | 6 +- 2 files changed, 7 insertions(+), 57 deletions(-) diff --git a/core/.phpstan-baseline.php b/core/.phpstan-baseline.php index b09dab6532d6..f1f8ceb847a3 100644 --- a/core/.phpstan-baseline.php +++ b/core/.phpstan-baseline.php @@ -1501,18 +1501,6 @@ 'count' => 1, 'path' => __DIR__ . '/lib/Drupal/Core/Action/ActionInterface.php', ]; -$ignoreErrors[] = [ - // identifier: class.notFound - 'message' => '#^Call to method getDefinitions\\(\\) on an unknown class Drupal\\\\Core\\\\Plugin\\\\CategorizingPluginManagerTrait\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/lib/Drupal/Core/Action/ActionManager.php', -]; -$ignoreErrors[] = [ - // identifier: class.notFound - 'message' => '#^Call to method getSortedDefinitions\\(\\) on an unknown class Drupal\\\\Core\\\\Plugin\\\\CategorizingPluginManagerTrait\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/lib/Drupal/Core/Action/ActionManager.php', -]; $ignoreErrors[] = [ // identifier: missingType.return 'message' => '#^Method Drupal\\\\Core\\\\Action\\\\ActionManager\\:\\:processDefinitionCategory\\(\\) has no return type specified\\.$#', @@ -2042,14 +2030,8 @@ 'path' => __DIR__ . '/lib/Drupal/Core/Block/BlockBase.php', ]; $ignoreErrors[] = [ - // identifier: class.notFound - 'message' => '#^Call to method getDefinitions\\(\\) on an unknown class Drupal\\\\Core\\\\Plugin\\\\CategorizingPluginManagerTrait\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/lib/Drupal/Core/Block/BlockManager.php', -]; -$ignoreErrors[] = [ - // identifier: class.notFound - 'message' => '#^Call to method getSortedDefinitions\\(\\) on an unknown class Drupal\\\\Core\\\\Plugin\\\\CategorizingPluginManagerTrait\\.$#', + // identifier: arguments.count + 'message' => '#^Method Drupal\\\\Core\\\\Block\\\\BlockManager\\:\\:getSortedDefinitions\\(\\) invoked with 2 parameters, 0\\-1 required\\.$#', 'count' => 1, 'path' => __DIR__ . '/lib/Drupal/Core/Block/BlockManager.php', ]; @@ -3049,18 +3031,6 @@ 'count' => 1, 'path' => __DIR__ . '/lib/Drupal/Core/Condition/ConditionInterface.php', ]; -$ignoreErrors[] = [ - // identifier: class.notFound - 'message' => '#^Call to method getDefinitions\\(\\) on an unknown class Drupal\\\\Core\\\\Plugin\\\\CategorizingPluginManagerTrait\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/lib/Drupal/Core/Condition/ConditionManager.php', -]; -$ignoreErrors[] = [ - // identifier: class.notFound - 'message' => '#^Call to method getSortedDefinitions\\(\\) on an unknown class Drupal\\\\Core\\\\Plugin\\\\CategorizingPluginManagerTrait\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/lib/Drupal/Core/Condition/ConditionManager.php', -]; $ignoreErrors[] = [ // identifier: missingType.return 'message' => '#^Method Drupal\\\\Core\\\\Condition\\\\ConditionManager\\:\\:getDefinitionsForContexts\\(\\) has no return type specified\\.$#', @@ -7386,18 +7356,6 @@ 'count' => 1, 'path' => __DIR__ . '/lib/Drupal/Core/Field/FieldStorageDefinitionListenerInterface.php', ]; -$ignoreErrors[] = [ - // identifier: class.notFound - 'message' => '#^Call to method getDefinitions\\(\\) on an unknown class Drupal\\\\Core\\\\Plugin\\\\CategorizingPluginManagerTrait\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/lib/Drupal/Core/Field/FieldTypePluginManager.php', -]; -$ignoreErrors[] = [ - // identifier: class.notFound - 'message' => '#^Call to method getSortedDefinitions\\(\\) on an unknown class Drupal\\\\Core\\\\Plugin\\\\CategorizingPluginManagerTrait\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/lib/Drupal/Core/Field/FieldTypePluginManager.php', -]; $ignoreErrors[] = [ // identifier: missingType.return 'message' => '#^Method Drupal\\\\Core\\\\Field\\\\FieldTypePluginManager\\:\\:getGroupedDefinitionsTrait\\(\\) has no return type specified\\.$#', @@ -61558,18 +61516,6 @@ 'count' => 1, 'path' => __DIR__ . '/tests/Drupal/Tests/Core/PathProcessor/PathProcessorFrontTest.php', ]; -$ignoreErrors[] = [ - // identifier: class.notFound - 'message' => '#^Call to method getDefinitions\\(\\) on an unknown class Drupal\\\\Core\\\\Plugin\\\\CategorizingPluginManagerTrait\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/tests/Drupal/Tests/Core/Plugin/CategorizingPluginManagerTraitTest.php', -]; -$ignoreErrors[] = [ - // identifier: class.notFound - 'message' => '#^Call to method getSortedDefinitions\\(\\) on an unknown class Drupal\\\\Core\\\\Plugin\\\\CategorizingPluginManagerTrait\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/tests/Drupal/Tests/Core/Plugin/CategorizingPluginManagerTraitTest.php', -]; $ignoreErrors[] = [ // identifier: missingType.return 'message' => '#^Method Drupal\\\\Tests\\\\Core\\\\Plugin\\\\CategorizingPluginManager\\:\\:processDefinitionCategory\\(\\) has no return type specified\\.$#', diff --git a/core/lib/Drupal/Core/Plugin/CategorizingPluginManagerTrait.php b/core/lib/Drupal/Core/Plugin/CategorizingPluginManagerTrait.php index e7dde93d0f84..5f341f07ce78 100644 --- a/core/lib/Drupal/Core/Plugin/CategorizingPluginManagerTrait.php +++ b/core/lib/Drupal/Core/Plugin/CategorizingPluginManagerTrait.php @@ -124,7 +124,6 @@ public function getSortedDefinitions(?array $definitions = NULL, $label_key = 'l * {@inheritdoc} */ public function getGroupedDefinitions(?array $definitions = NULL, $label_key = 'label') { - /** @var \Drupal\Core\Plugin\CategorizingPluginManagerTrait|\Drupal\Component\Plugin\PluginManagerInterface $this */ $definitions = $this->getSortedDefinitions($definitions ?? $this->getDefinitions(), $label_key); $grouped_definitions = []; foreach ($definitions as $id => $definition) { @@ -133,4 +132,9 @@ public function getGroupedDefinitions(?array $definitions = NULL, $label_key = ' return $grouped_definitions; } + /** + * {@inheritdoc} + */ + abstract public function getDefinitions(); + } -- GitLab