diff --git a/core/lib/Drupal/Core/Asset/AssetResolver.php b/core/lib/Drupal/Core/Asset/AssetResolver.php index 6f477d19f6..6748dc6851 100644 --- a/core/lib/Drupal/Core/Asset/AssetResolver.php +++ b/core/lib/Drupal/Core/Asset/AssetResolver.php @@ -155,7 +155,7 @@ public function getCssAssets(AttachedAssetsInterface $assets, $optimize) { $this->themeManager->alter('css', $css, $assets); // Sort CSS items, so that they appear in the correct order. - uasort($css, [static::class, 'sort']); + uasort($css, static::sort(...)); if ($optimize) { $css = \Drupal::service('asset.css.collection_optimizer')->optimize($css); @@ -262,7 +262,7 @@ public function getJsAssets(AttachedAssetsInterface $assets, $optimize) { $this->themeManager->alter('js', $javascript, $assets); // Sort JavaScript assets, so that they appear in the correct order. - uasort($javascript, [static::class, 'sort']); + uasort($javascript, static::sort(...)); // Prepare the return value: filter JavaScript assets per scope. $js_assets_header = []; diff --git a/core/lib/Drupal/Core/Render/Element.php b/core/lib/Drupal/Core/Render/Element.php index 27e4d1ab05..b862a0b003 100644 --- a/core/lib/Drupal/Core/Render/Element.php +++ b/core/lib/Drupal/Core/Render/Element.php @@ -37,7 +37,7 @@ public static function property($key) { * An array of property keys for the element. */ public static function properties(array $element) { - return array_filter(array_keys($element), [static::class, 'property']); + return array_filter(array_keys($element), static::property(...)); } /** diff --git a/core/lib/Drupal/Core/Template/DebugExtension.php b/core/lib/Drupal/Core/Template/DebugExtension.php index 15696aebae..80bf41e9d9 100644 --- a/core/lib/Drupal/Core/Template/DebugExtension.php +++ b/core/lib/Drupal/Core/Template/DebugExtension.php @@ -30,7 +30,7 @@ public function getFunctions(): array { // @see \Symfony\Component\VarDumper\VarDumper if (class_exists(self::SYMFONY_VAR_DUMPER_CLASS)) { return [ - new TwigFunction('dump', [self::class, 'dump'], ['needs_context' => TRUE, 'needs_environment' => TRUE, 'is_variadic' => TRUE]), + new TwigFunction('dump', self::dump(...), ['needs_context' => TRUE, 'needs_environment' => TRUE, 'is_variadic' => TRUE]), ]; } diff --git a/core/modules/block/src/BlockViewBuilder.php b/core/modules/block/src/BlockViewBuilder.php index b4cdf0c7aa..8c5b068f9f 100644 --- a/core/modules/block/src/BlockViewBuilder.php +++ b/core/modules/block/src/BlockViewBuilder.php @@ -123,7 +123,7 @@ protected static function buildPreRenderableBlock(BlockInterface $entity, Module '#derivative_plugin_id' => $derivative_id, '#id' => $entity->id(), '#pre_render' => [ - static::class . '::preRender', + static::preRender(...), ], // Add the entity so that it can be used in the #pre_render method. '#block' => $entity, diff --git a/core/modules/ckeditor5/src/HTMLRestrictions.php b/core/modules/ckeditor5/src/HTMLRestrictions.php index 68cd0589e5..73e7dcdcb9 100644 --- a/core/modules/ckeditor5/src/HTMLRestrictions.php +++ b/core/modules/ckeditor5/src/HTMLRestrictions.php @@ -1390,7 +1390,8 @@ private static function getHtml5ElementList(): array { */ private static function getWildcardTags(string $wildcard): array { $wildcard_element_method = self::WILDCARD_ELEMENT_METHODS[$wildcard]; - return call_user_func([self::class, $wildcard_element_method]); + $callable = self::$wildcard_element_method(...); + return $callable(); } } diff --git a/core/modules/field_ui/src/Element/FieldUiTable.php b/core/modules/field_ui/src/Element/FieldUiTable.php index 10200fdd38..3f0f9ce9f8 100644 --- a/core/modules/field_ui/src/Element/FieldUiTable.php +++ b/core/modules/field_ui/src/Element/FieldUiTable.php @@ -108,7 +108,7 @@ public static function tablePreRender($elements) { // Determine rendering order from the tree structure. foreach ($regions as $region_name => $region) { - $elements['#regions'][$region_name]['rows_order'] = array_reduce($trees[$region_name], [static::class, 'reduceOrder']); + $elements['#regions'][$region_name]['rows_order'] = array_reduce($trees[$region_name], static::reduceOrder(...)); } $elements['#attached']['drupalSettings']['fieldUIRowsData'] = $js_settings; @@ -233,7 +233,7 @@ public static function reduceOrder($array, $a) { } if (!empty($a['children'])) { uasort($a['children'], ['Drupal\Component\Utility\SortArray', 'sortByWeightElement']); - $array = array_merge($array, array_reduce($a['children'], [static::class, 'reduceOrder'])); + $array = array_merge($array, array_reduce($a['children'], static::reduceOrder(...))); } return $array; diff --git a/core/modules/jsonapi/tests/src/Functional/ResourceResponseTestTrait.php b/core/modules/jsonapi/tests/src/Functional/ResourceResponseTestTrait.php index 993ff5b57b..7df0eb701e 100644 --- a/core/modules/jsonapi/tests/src/Functional/ResourceResponseTestTrait.php +++ b/core/modules/jsonapi/tests/src/Functional/ResourceResponseTestTrait.php @@ -217,7 +217,7 @@ protected function getExpectedIncludedResourceResponse(array $include_paths, arr * The ResourceResponses. */ protected static function toResourceResponses(array $responses) { - return array_map([self::class, 'toResourceResponse'], $responses); + return array_map(self::toResourceResponse(...), $responses); } /** @@ -365,7 +365,7 @@ protected static function extractLinks(array $link_paths, array $document) { * The resource links. */ protected static function getResourceLinks(array $resource_identifiers) { - return array_map([static::class, 'getResourceLink'], $resource_identifiers); + return array_map(static::getResourceLink(...), $resource_identifiers); } /** diff --git a/core/modules/jsonapi/tests/src/Functional/ResourceTestBase.php b/core/modules/jsonapi/tests/src/Functional/ResourceTestBase.php index 0092a95e97..189738d264 100644 --- a/core/modules/jsonapi/tests/src/Functional/ResourceTestBase.php +++ b/core/modules/jsonapi/tests/src/Functional/ResourceTestBase.php @@ -1254,7 +1254,7 @@ public function testCollection() { * @see \GuzzleHttp\ClientInterface::request() */ protected function getExpectedCollectionResponse(array $collection, $self_link, array $request_options, array $included_paths = NULL, $filtered = FALSE) { - $resource_identifiers = array_map([static::class, 'toResourceIdentifier'], $collection); + $resource_identifiers = array_map(static::toResourceIdentifier(...), $collection); $individual_responses = static::toResourceResponses($this->getResponses(static::getResourceLinks($resource_identifiers), $request_options)); $merged_response = static::toCollectionResourceResponse($individual_responses, $self_link, TRUE); diff --git a/core/modules/views/src/Plugin/views/filter/FilterPluginBase.php b/core/modules/views/src/Plugin/views/filter/FilterPluginBase.php index 6e0bc80dcc..6e8c8a6bbb 100644 --- a/core/modules/views/src/Plugin/views/filter/FilterPluginBase.php +++ b/core/modules/views/src/Plugin/views/filter/FilterPluginBase.php @@ -706,7 +706,7 @@ protected function hasValidGroupedValue(array $group) { // types). Ensure at least the minimum number of values is present for // this entry to be considered valid. $min_values = $operators[$group['operator']]['values']; - $actual_values = count(array_filter($group['value'], [static::class, 'arrayFilterZero'])); + $actual_values = count(array_filter($group['value'], static::arrayFilterZero(...))); return $actual_values >= $min_values; } } diff --git a/core/modules/views/src/Plugin/views/filter/ManyToOne.php b/core/modules/views/src/Plugin/views/filter/ManyToOne.php index 9fd8a42fe8..ef98c51ead 100644 --- a/core/modules/views/src/Plugin/views/filter/ManyToOne.php +++ b/core/modules/views/src/Plugin/views/filter/ManyToOne.php @@ -132,7 +132,7 @@ protected function opHelper() { } // Form API returns unchecked options in the form of option_id => 0. This // breaks the generated query for "is all of" filters so we remove them. - $this->value = array_filter($this->value, [static::class, 'arrayFilterZero']); + $this->value = array_filter($this->value, static::arrayFilterZero(...)); $this->helper->addFilter(); } diff --git a/core/modules/views/src/Views.php b/core/modules/views/src/Views.php index 33ec07304a..3b9d4584b0 100644 --- a/core/modules/views/src/Views.php +++ b/core/modules/views/src/Views.php @@ -307,8 +307,8 @@ public static function getViewsAsOptions($views_only = FALSE, $filter = 'all', $ case 'all': case 'disabled': case 'enabled': - $filter = ucfirst($filter); - $views = call_user_func(static::class . "::get{$filter}Views"); + $callable = ('static::get' . ucfirst($filter) . 'Views')(...); + $views = $callable(); break; default: