diff --git a/core/.deprecation-ignore.txt b/core/.deprecation-ignore.txt index 12772fbb55bc6ce068abe821243c77c265bc5be8..d52cdb75b038a444fa81d29348a6bc2b552e61c5 100644 --- a/core/.deprecation-ignore.txt +++ b/core/.deprecation-ignore.txt @@ -39,6 +39,8 @@ %The "Drupal\\Core\\Database\\Query\\SelectExtender::hasAnyTag\(\)" method will require a new "string \.\.\. \$tags" argument in the next major version of its interface% %The "Drupal\\Core\\Entity\\Query\\QueryBase::hasAllTags\(\)" method will require a new "string \.\.\. \$tags" argument in the next major version of its interface% %The "Drupal\\Core\\Entity\\Query\\QueryBase::hasAnyTag\(\)" method will require a new "string \.\.\. \$tags" argument in the next major version of its interface% +%The "Drupal\\.*::execute\(\)" method will require a new "object\|null \$object" argument in the next major version of its interface "Drupal\\Core\\Executable\\ExecutableInterface"% +%The "Drupal\\.*::get(?:Sorted|Grouped)Definitions\(\)" method will require a new "string \$label_key" argument in the next major version of its interface "Drupal\\Component\\Plugin\\CategorizingPluginManagerInterface"% # Symfony 7.3. %Since symfony/validator 7.3: Passing an array of options to configure the "[^"]+" constraint is deprecated, use named arguments instead.% diff --git a/core/.phpstan-baseline.php b/core/.phpstan-baseline.php index f538d08ddb2d6ebd8c1f6f62492ad4b3a6d8cfd6..67943d8ec929bbc7e8845ef20b9ec07d3266baaa 100644 --- a/core/.phpstan-baseline.php +++ b/core/.phpstan-baseline.php @@ -1219,12 +1219,6 @@ 'count' => 1, 'path' => __DIR__ . '/lib/Drupal/Core/Action/ActionBase.php', ]; -$ignoreErrors[] = [ - 'message' => '#^Method Drupal\\\\Core\\\\Executable\\\\ExecutableInterface\\:\\:execute\\(\\) invoked with 1 parameter, 0 required\\.$#', - 'identifier' => 'arguments.count', - 'count' => 1, - 'path' => __DIR__ . '/lib/Drupal/Core/Action/ActionBase.php', -]; $ignoreErrors[] = [ 'message' => '#^Method Drupal\\\\Core\\\\Action\\\\ActionInterface\\:\\:executeMultiple\\(\\) has no return type specified\\.$#', 'identifier' => 'missingType.return', @@ -1759,12 +1753,6 @@ 'count' => 1, 'path' => __DIR__ . '/lib/Drupal/Core/Block/BlockBase.php', ]; -$ignoreErrors[] = [ - 'message' => '#^Method Drupal\\\\Core\\\\Block\\\\BlockManager\\:\\:getSortedDefinitions\\(\\) invoked with 2 parameters, 0\\-1 required\\.$#', - 'identifier' => 'arguments.count', - 'count' => 1, - 'path' => __DIR__ . '/lib/Drupal/Core/Block/BlockManager.php', -]; $ignoreErrors[] = [ 'message' => '#^Method Drupal\\\\Core\\\\Block\\\\BlockManager\\:\\:processDefinition\\(\\) has no return type specified\\.$#', 'identifier' => 'missingType.return', @@ -5953,12 +5941,6 @@ 'count' => 1, 'path' => __DIR__ . '/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorageSchema.php', ]; -$ignoreErrors[] = [ - 'message' => '#^Method Drupal\\\\Core\\\\Entity\\\\Sql\\\\SqlContentEntityStorageSchema\\:\\:addUniqueKey\\(\\) invoked with 4 parameters, 3 required\\.$#', - 'identifier' => 'arguments.count', - 'count' => 1, - 'path' => __DIR__ . '/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorageSchema.php', -]; $ignoreErrors[] = [ 'message' => '#^Method Drupal\\\\Core\\\\Entity\\\\Sql\\\\SqlContentEntityStorageSchema\\:\\:copyData\\(\\) has no return type specified\\.$#', 'identifier' => 'missingType.return', diff --git a/core/lib/Drupal/Component/Plugin/CategorizingPluginManagerInterface.php b/core/lib/Drupal/Component/Plugin/CategorizingPluginManagerInterface.php index d6d1e37067eff06ff743eb6345ef2f425661ded8..17dcd81418c3acfa401f7fdac8abdbe4664aacc5 100644 --- a/core/lib/Drupal/Component/Plugin/CategorizingPluginManagerInterface.php +++ b/core/lib/Drupal/Component/Plugin/CategorizingPluginManagerInterface.php @@ -15,17 +15,23 @@ interface CategorizingPluginManagerInterface extends PluginManagerInterface { */ public function getCategories(); + // phpcs:disable Drupal.Commenting + /** * Gets sorted plugin definitions. * * @param array[]|null $definitions * (optional) The plugin definitions to sort. If omitted, all plugin * definitions are used. + * @todo Uncomment new method parameter before drupal:12.0.0. + * @see https://www.drupal.org/project/drupal/issues/3354672 + * @param string $label_key + * (optional) The key to be used as a label for sorting. * * @return array[] * An array of plugin definitions, sorted by category and label. */ - public function getSortedDefinitions(?array $definitions = NULL); + public function getSortedDefinitions(?array $definitions = NULL /*, string $label_key = 'label' */); /** * Gets sorted plugin definitions grouped by category. @@ -36,11 +42,17 @@ public function getSortedDefinitions(?array $definitions = NULL); * @param array[]|null $definitions * (optional) The plugin definitions to group. If omitted, all plugin * definitions are used. + * @todo Uncomment new method parameter before drupal:12.0.0. + * @see https://www.drupal.org/project/drupal/issues/3354672 + * @param string $label_key + * (optional) The key to be used as a label for sorting. * * @return array[] * Keys are category names, and values are arrays of which the keys are * plugin IDs and the values are plugin definitions. */ - public function getGroupedDefinitions(?array $definitions = NULL); + public function getGroupedDefinitions(?array $definitions = NULL /*, string $label_key = 'label' */); + + // phpcs:enable } diff --git a/core/lib/Drupal/Core/Action/ActionBase.php b/core/lib/Drupal/Core/Action/ActionBase.php index cb009c30efd55e486c373b063dd8b7bf10c7fc8f..5c8ccbca1e1bfadf8177196504421227e2525086 100644 --- a/core/lib/Drupal/Core/Action/ActionBase.php +++ b/core/lib/Drupal/Core/Action/ActionBase.php @@ -19,6 +19,7 @@ abstract class ActionBase extends PluginBase implements ActionInterface { */ public function executeMultiple(array $entities) { foreach ($entities as $entity) { + // @phpstan-ignore arguments.count $this->execute($entity); } } diff --git a/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorageSchema.php b/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorageSchema.php index 6473a846133fa1f8f5624198c4b4617bd8387c66..f09c590693ee8c2c1c424f24ea286571decfcb90 100644 --- a/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorageSchema.php +++ b/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorageSchema.php @@ -1935,17 +1935,12 @@ protected function createEntitySchemaIndexes(array $entity_schema, ?FieldStorage $column_names = $table_mapping->getColumnNames($storage_definition->getName()); } - $index_keys = [ - 'indexes' => 'addIndex', - 'unique keys' => 'addUniqueKey', - ]; - foreach ($this->getEntitySchemaData($this->entityType, $entity_schema) as $table_name => $schema) { // Add fields schema because database driver may depend on this data to // perform index normalization. $schema['fields'] = $entity_schema[$table_name]['fields']; - foreach ($index_keys as $key => $add_method) { + foreach (['indexes', 'unique keys'] as $key) { if (!empty($schema[$key])) { foreach ($schema[$key] as $name => $specifier) { // If a set of field columns were specified we process only indexes @@ -1968,7 +1963,10 @@ protected function createEntitySchemaIndexes(array $entity_schema, ?FieldStorage } } if ($create) { - $this->{$add_method}($table_name, $name, $specifier, $schema); + match ($key) { + 'indexes' => $this->addIndex($table_name, $name, $specifier, $schema), + 'unique keys' => $this->addUniqueKey($table_name, $name, $specifier), + }; } } } diff --git a/core/lib/Drupal/Core/Executable/ExecutableInterface.php b/core/lib/Drupal/Core/Executable/ExecutableInterface.php index b5967505540a0981fedb9ed0810d3471f21ea62f..235169cdc38e63feddad6329798bacf0a79b971f 100644 --- a/core/lib/Drupal/Core/Executable/ExecutableInterface.php +++ b/core/lib/Drupal/Core/Executable/ExecutableInterface.php @@ -11,7 +11,14 @@ interface ExecutableInterface { /** * Executes the plugin. + * + * phpcs:disable Drupal.Commenting + * @todo Uncomment new method parameter before drupal:12.0.0. + * @see https://www.drupal.org/project/drupal/issues/3354672 + * + * @param object|null $object + * (Optional) An object to execute the plugin on/with. */ - public function execute(); + public function execute(/* ?object $object = NULL */); } diff --git a/core/lib/Drupal/Core/Plugin/CategorizingPluginManagerTrait.php b/core/lib/Drupal/Core/Plugin/CategorizingPluginManagerTrait.php index 5f341f07ce78132902ce475fca180fed7ec3a800..b1239e2e71a1c895ec86a70333c6e59a2885eb54 100644 --- a/core/lib/Drupal/Core/Plugin/CategorizingPluginManagerTrait.php +++ b/core/lib/Drupal/Core/Plugin/CategorizingPluginManagerTrait.php @@ -108,7 +108,7 @@ public function getCategories() { /** * {@inheritdoc} */ - public function getSortedDefinitions(?array $definitions = NULL, $label_key = 'label') { + public function getSortedDefinitions(?array $definitions = NULL, string $label_key = 'label') { // Sort the plugins first by category, then by label. $definitions = $definitions ?? $this->getDefinitions(); uasort($definitions, function ($a, $b) use ($label_key) { @@ -123,7 +123,8 @@ public function getSortedDefinitions(?array $definitions = NULL, $label_key = 'l /** * {@inheritdoc} */ - public function getGroupedDefinitions(?array $definitions = NULL, $label_key = 'label') { + public function getGroupedDefinitions(?array $definitions = NULL, string $label_key = 'label') { + // @phpstan-ignore arguments.count $definitions = $this->getSortedDefinitions($definitions ?? $this->getDefinitions(), $label_key); $grouped_definitions = []; foreach ($definitions as $id => $definition) {