From 75edbfda93c2759e7f98a044c49479351a24a21c Mon Sep 17 00:00:00 2001 From: quietone <quietone@2572884.no-reply.drupal.org> Date: Fri, 20 Dec 2024 13:05:40 +1300 Subject: [PATCH] Issue #3494678 by mstrelan, nicxvan: Add void return type to all procedural alter hook implementations (cherry picked from commit 053c43e3eef8c88670bd776d9f5ae6945344f0c6) --- core/.phpstan-baseline.php | 222 ------------------ core/modules/ckeditor5/ckeditor5.module | 2 +- .../content_translation.module | 2 +- .../layout_builder/layout_builder.module | 2 +- .../layout_builder_test.module | 2 +- .../media_library_form_overwrite_test.module | 2 +- core/modules/navigation/navigation.module | 2 +- .../modules/common_test/common_test.module | 4 +- .../deprecation_test/deprecation_test.module | 2 +- .../modules/module_test/module_test.module | 4 +- .../unversioned_assets_test.module | 2 +- .../tests/themes/test_theme/test_theme.theme | 14 +- .../views_ui_test_theme.theme | 4 +- .../demo_umami/themes/umami/umami.theme | 2 +- core/themes/claro/claro.theme | 20 +- core/themes/olivero/olivero.theme | 10 +- 16 files changed, 37 insertions(+), 259 deletions(-) diff --git a/core/.phpstan-baseline.php b/core/.phpstan-baseline.php index 53f992cc4fdd..31a62b25dbb6 100644 --- a/core/.phpstan-baseline.php +++ b/core/.phpstan-baseline.php @@ -12598,12 +12598,6 @@ 'count' => 1, 'path' => __DIR__ . '/modules/ckeditor5/ckeditor5.module', ]; -$ignoreErrors[] = [ - // identifier: missingType.return - 'message' => '#^Function ckeditor5_module_implements_alter\\(\\) has no return type specified\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/modules/ckeditor5/ckeditor5.module', -]; $ignoreErrors[] = [ // identifier: missingType.return 'message' => '#^Method Drupal\\\\ckeditor5\\\\Annotation\\\\CKEditor5Plugin\\:\\:setClass\\(\\) has no return type specified\\.$#', @@ -16552,12 +16546,6 @@ 'count' => 1, 'path' => __DIR__ . '/modules/content_translation/content_translation.module', ]; -$ignoreErrors[] = [ - // identifier: missingType.return - 'message' => '#^Function content_translation_module_implements_alter\\(\\) has no return type specified\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/modules/content_translation/content_translation.module', -]; $ignoreErrors[] = [ // identifier: variable.undefined 'message' => '#^Variable \\$locked_languages might not be defined\\.$#', @@ -23662,12 +23650,6 @@ 'count' => 1, 'path' => __DIR__ . '/modules/language/tests/src/Unit/Menu/LanguageLocalTasksTest.php', ]; -$ignoreErrors[] = [ - // identifier: missingType.return - 'message' => '#^Function layout_builder_module_implements_alter\\(\\) has no return type specified\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/modules/layout_builder/layout_builder.module', -]; $ignoreErrors[] = [ // identifier: missingType.return 'message' => '#^Method Drupal\\\\layout_builder_expose_all_field_blocks\\\\Hook\\\\LayoutBuilderExposeAllFieldBlocksHooks\\:\\:help\\(\\) has no return type specified\\.$#', @@ -24286,12 +24268,6 @@ 'count' => 1, 'path' => __DIR__ . '/modules/layout_builder/tests/modules/layout_builder_form_block_test/src/Plugin/Block/TestFormApiFormBlock.php', ]; -$ignoreErrors[] = [ - // identifier: missingType.return - 'message' => '#^Function layout_builder_test_module_implements_alter\\(\\) has no return type specified\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/modules/layout_builder/tests/modules/layout_builder_test/layout_builder_test.module', -]; $ignoreErrors[] = [ // identifier: missingType.return 'message' => '#^Function layout_builder_test_node_view\\(\\) has no return type specified\\.$#', @@ -27118,12 +27094,6 @@ 'count' => 1, 'path' => __DIR__ . '/modules/media_library/src/Routing/RouteSubscriber.php', ]; -$ignoreErrors[] = [ - // identifier: missingType.return - 'message' => '#^Function media_library_form_overwrite_test_media_source_info_alter\\(\\) has no return type specified\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/modules/media_library/tests/modules/media_library_form_overwrite_test/media_library_form_overwrite_test.module', -]; $ignoreErrors[] = [ // identifier: missingType.return 'message' => '#^Method Drupal\\\\media_library_test\\\\Form\\\\TestNodeFormOverride\\:\\:submitForm\\(\\) has no return type specified\\.$#', @@ -29976,12 +29946,6 @@ 'count' => 1, 'path' => __DIR__ . '/modules/navigation/navigation.install', ]; -$ignoreErrors[] = [ - // identifier: missingType.return - 'message' => '#^Function navigation_module_implements_alter\\(\\) has no return type specified\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/modules/navigation/navigation.module', -]; $ignoreErrors[] = [ // identifier: missingType.return 'message' => '#^Function navigation_post_update_set_logo_dimensions_default\\(\\) has no return type specified\\.$#', @@ -36144,24 +36108,12 @@ 'count' => 1, 'path' => __DIR__ . '/modules/system/tests/modules/cache_test/src/Controller/CacheTestController.php', ]; -$ignoreErrors[] = [ - // identifier: missingType.return - 'message' => '#^Function common_test_module_implements_alter\\(\\) has no return type specified\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/modules/system/tests/modules/common_test/common_test.module', -]; $ignoreErrors[] = [ // identifier: missingType.return 'message' => '#^Function common_test_preprocess\\(\\) has no return type specified\\.$#', 'count' => 1, 'path' => __DIR__ . '/modules/system/tests/modules/common_test/common_test.module', ]; -$ignoreErrors[] = [ - // identifier: missingType.return - 'message' => '#^Function olivero_drupal_alter_alter\\(\\) has no return type specified\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/modules/system/tests/modules/common_test/common_test.module', -]; $ignoreErrors[] = [ // identifier: missingType.return 'message' => '#^Method Drupal\\\\common_test\\\\Controller\\\\CommonTestController\\:\\:typeLinkActiveClass\\(\\) has no return type specified\\.$#', @@ -36282,12 +36234,6 @@ 'count' => 1, 'path' => __DIR__ . '/modules/system/tests/modules/delay_cache_tags_invalidation/src/Hook/DelayCacheTagsInvalidationHooks.php', ]; -$ignoreErrors[] = [ - // identifier: missingType.return - 'message' => '#^Function deprecation_test_deprecated_alter_alter\\(\\) has no return type specified\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/modules/system/tests/modules/deprecation_test/deprecation_test.module', -]; $ignoreErrors[] = [ // identifier: missingType.return 'message' => '#^Function deprecation_test_deprecated_hook\\(\\) has no return type specified\\.$#', @@ -38767,12 +38713,6 @@ 'count' => 1, 'path' => __DIR__ . '/modules/system/tests/modules/module_test/module_test.module', ]; -$ignoreErrors[] = [ - // identifier: missingType.return - 'message' => '#^Function module_test_module_implements_alter\\(\\) has no return type specified\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/modules/system/tests/modules/module_test/module_test.module', -]; $ignoreErrors[] = [ // identifier: missingType.return 'message' => '#^Function module_test_modules_installed\\(\\) has no return type specified\\.$#', @@ -38785,12 +38725,6 @@ 'count' => 1, 'path' => __DIR__ . '/modules/system/tests/modules/module_test/module_test.module', ]; -$ignoreErrors[] = [ - // identifier: missingType.return - 'message' => '#^Function module_test_system_info_alter\\(\\) has no return type specified\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/modules/system/tests/modules/module_test/module_test.module', -]; $ignoreErrors[] = [ // identifier: missingType.return 'message' => '#^Function module_test_post_update_test\\(\\) has no return type specified\\.$#', @@ -39741,12 +39675,6 @@ 'count' => 1, 'path' => __DIR__ . '/modules/system/tests/modules/twig_theme_test/twig_theme_test.module', ]; -$ignoreErrors[] = [ - // identifier: missingType.return - 'message' => '#^Function unversioned_assets_test_library_info_alter\\(\\) has no return type specified\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/modules/system/tests/modules/unversioned_assets_test/unversioned_assets_test.module', -]; $ignoreErrors[] = [ // identifier: missingType.return 'message' => '#^Method Drupal\\\\update_script_test\\\\Controller\\\\UpdateScriptTestController\\:\\:databaseUpdatesMenuItem\\(\\) has no return type specified\\.$#', @@ -41655,48 +41583,6 @@ 'count' => 1, 'path' => __DIR__ . '/modules/system/tests/themes/test_subtheme/test_subtheme.theme', ]; -$ignoreErrors[] = [ - // identifier: missingType.return - 'message' => '#^Function test_theme_element_info_alter\\(\\) has no return type specified\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/modules/system/tests/themes/test_theme/test_theme.theme', -]; -$ignoreErrors[] = [ - // identifier: missingType.return - 'message' => '#^Function test_theme_library_info_alter\\(\\) has no return type specified\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/modules/system/tests/themes/test_theme/test_theme.theme', -]; -$ignoreErrors[] = [ - // identifier: missingType.return - 'message' => '#^Function test_theme_theme_registry_alter\\(\\) has no return type specified\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/modules/system/tests/themes/test_theme/test_theme.theme', -]; -$ignoreErrors[] = [ - // identifier: missingType.return - 'message' => '#^Function test_theme_theme_suggestions_alter\\(\\) has no return type specified\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/modules/system/tests/themes/test_theme/test_theme.theme', -]; -$ignoreErrors[] = [ - // identifier: missingType.return - 'message' => '#^Function test_theme_theme_suggestions_node_alter\\(\\) has no return type specified\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/modules/system/tests/themes/test_theme/test_theme.theme', -]; -$ignoreErrors[] = [ - // identifier: missingType.return - 'message' => '#^Function test_theme_theme_suggestions_theme_test_suggestions_alter\\(\\) has no return type specified\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/modules/system/tests/themes/test_theme/test_theme.theme', -]; -$ignoreErrors[] = [ - // identifier: missingType.return - 'message' => '#^Function test_theme_theme_test_alter_alter\\(\\) has no return type specified\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/modules/system/tests/themes/test_theme/test_theme.theme', -]; $ignoreErrors[] = [ // identifier: missingType.return 'message' => '#^Function test_theme_depending_on_modules_post_update_module_install\\(\\) has no return type specified\\.$#', @@ -53703,18 +53589,6 @@ 'count' => 1, 'path' => __DIR__ . '/modules/views_ui/tests/src/FunctionalJavascript/PreviewTest.php', ]; -$ignoreErrors[] = [ - // identifier: missingType.return - 'message' => '#^Function views_ui_test_theme_views_ui_display_tab_alter\\(\\) has no return type specified\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/modules/views_ui/tests/themes/views_ui_test_theme/views_ui_test_theme.theme', -]; -$ignoreErrors[] = [ - // identifier: missingType.return - 'message' => '#^Function views_ui_test_theme_views_ui_display_top_alter\\(\\) has no return type specified\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/modules/views_ui/tests/themes/views_ui_test_theme/views_ui_test_theme.theme', -]; $ignoreErrors[] = [ // identifier: missingType.return 'message' => '#^Function views_ui_contextual_links_suppress\\(\\) has no return type specified\\.$#', @@ -55719,12 +55593,6 @@ 'count' => 1, 'path' => __DIR__ . '/profiles/demo_umami/tests/src/Functional/DemoUmamiProfileTest.php', ]; -$ignoreErrors[] = [ - // identifier: missingType.return - 'message' => '#^Function umami_theme_suggestions_block_alter\\(\\) has no return type specified\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/profiles/demo_umami/themes/umami/umami.theme', -]; $ignoreErrors[] = [ // identifier: missingType.return 'message' => '#^Method Drupal\\\\Tests\\\\minimal\\\\Functional\\\\MinimalTest\\:\\:assertConfigSchema\\(\\) has no return type specified\\.$#', @@ -62588,72 +62456,12 @@ 'count' => 1, 'path' => __DIR__ . '/themes/claro/claro.theme', ]; -$ignoreErrors[] = [ - // identifier: missingType.return - 'message' => '#^Function claro_element_info_alter\\(\\) has no return type specified\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/themes/claro/claro.theme', -]; -$ignoreErrors[] = [ - // identifier: missingType.return - 'message' => '#^Function claro_page_attachments_alter\\(\\) has no return type specified\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/themes/claro/claro.theme', -]; -$ignoreErrors[] = [ - // identifier: missingType.return - 'message' => '#^Function claro_system_module_invoked_library_info_alter\\(\\) has no return type specified\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/themes/claro/claro.theme', -]; -$ignoreErrors[] = [ - // identifier: missingType.return - 'message' => '#^Function claro_system_module_invoked_theme_registry_alter\\(\\) has no return type specified\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/themes/claro/claro.theme', -]; -$ignoreErrors[] = [ - // identifier: missingType.return - 'message' => '#^Function claro_theme_registry_alter\\(\\) has no return type specified\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/themes/claro/claro.theme', -]; -$ignoreErrors[] = [ - // identifier: missingType.return - 'message' => '#^Function claro_theme_suggestions_details_alter\\(\\) has no return type specified\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/themes/claro/claro.theme', -]; -$ignoreErrors[] = [ - // identifier: missingType.return - 'message' => '#^Function claro_theme_suggestions_form_element_alter\\(\\) has no return type specified\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/themes/claro/claro.theme', -]; -$ignoreErrors[] = [ - // identifier: missingType.return - 'message' => '#^Function claro_theme_suggestions_maintenance_page_alter\\(\\) has no return type specified\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/themes/claro/claro.theme', -]; $ignoreErrors[] = [ // identifier: missingType.return 'message' => '#^Function claro_views_pre_render\\(\\) has no return type specified\\.$#', 'count' => 1, 'path' => __DIR__ . '/themes/claro/claro.theme', ]; -$ignoreErrors[] = [ - // identifier: missingType.return - 'message' => '#^Function claro_views_ui_display_tab_alter\\(\\) has no return type specified\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/themes/claro/claro.theme', -]; -$ignoreErrors[] = [ - // identifier: missingType.return - 'message' => '#^Function claro_views_ui_display_top_alter\\(\\) has no return type specified\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/themes/claro/claro.theme', -]; $ignoreErrors[] = [ // identifier: missingType.return 'message' => '#^Method Drupal\\\\claro\\\\ClaroPreRender\\:\\:managedFile\\(\\) has no return type specified\\.$#', @@ -62690,36 +62498,6 @@ 'count' => 1, 'path' => __DIR__ . '/themes/engines/twig/twig.engine', ]; -$ignoreErrors[] = [ - // identifier: missingType.return - 'message' => '#^Function olivero_element_info_alter\\(\\) has no return type specified\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/themes/olivero/olivero.theme', -]; -$ignoreErrors[] = [ - // identifier: missingType.return - 'message' => '#^Function olivero_theme_suggestions_block_alter\\(\\) has no return type specified\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/themes/olivero/olivero.theme', -]; -$ignoreErrors[] = [ - // identifier: missingType.return - 'message' => '#^Function olivero_theme_suggestions_form_alter\\(\\) has no return type specified\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/themes/olivero/olivero.theme', -]; -$ignoreErrors[] = [ - // identifier: missingType.return - 'message' => '#^Function olivero_theme_suggestions_menu_alter\\(\\) has no return type specified\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/themes/olivero/olivero.theme', -]; -$ignoreErrors[] = [ - // identifier: missingType.return - 'message' => '#^Function olivero_theme_suggestions_user_alter\\(\\) has no return type specified\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/themes/olivero/olivero.theme', -]; $ignoreErrors[] = [ // identifier: missingType.return 'message' => '#^Method Drupal\\\\olivero\\\\OliveroPreRender\\:\\:textFormat\\(\\) has no return type specified\\.$#', diff --git a/core/modules/ckeditor5/ckeditor5.module b/core/modules/ckeditor5/ckeditor5.module index caa6f3f50dab..62f6cfba703d 100644 --- a/core/modules/ckeditor5/ckeditor5.module +++ b/core/modules/ckeditor5/ckeditor5.module @@ -20,7 +20,7 @@ /** * Implements hook_module_implements_alter(). */ -function ckeditor5_module_implements_alter(&$implementations, $hook) { +function ckeditor5_module_implements_alter(&$implementations, $hook): void { // This module's implementation of form_filter_format_form_alter() must happen // after the editor module's implementation, as that implementation adds the // active editor to $form_state. It must also happen after the media module's diff --git a/core/modules/content_translation/content_translation.module b/core/modules/content_translation/content_translation.module index 7b6388deca0b..a4a023d8b7c5 100644 --- a/core/modules/content_translation/content_translation.module +++ b/core/modules/content_translation/content_translation.module @@ -13,7 +13,7 @@ /** * Implements hook_module_implements_alter(). */ -function content_translation_module_implements_alter(&$implementations, $hook) { +function content_translation_module_implements_alter(&$implementations, $hook): void { switch ($hook) { // Move our hook_entity_type_alter() implementation to the end of the list. case 'entity_type_alter': diff --git a/core/modules/layout_builder/layout_builder.module b/core/modules/layout_builder/layout_builder.module index c79b92db26d9..32ce8bee9459 100644 --- a/core/modules/layout_builder/layout_builder.module +++ b/core/modules/layout_builder/layout_builder.module @@ -9,7 +9,7 @@ /** * Implements hook_module_implements_alter(). */ -function layout_builder_module_implements_alter(&$implementations, $hook) { +function layout_builder_module_implements_alter(&$implementations, $hook): void { if ($hook === 'entity_view_alter') { // Ensure that this module's implementation of hook_entity_view_alter() runs // last so that other modules that use this hook to render extra fields will diff --git a/core/modules/layout_builder/tests/modules/layout_builder_test/layout_builder_test.module b/core/modules/layout_builder/tests/modules/layout_builder_test/layout_builder_test.module index 6a876a7a16f8..752a5d17a793 100644 --- a/core/modules/layout_builder/tests/modules/layout_builder_test/layout_builder_test.module +++ b/core/modules/layout_builder/tests/modules/layout_builder_test/layout_builder_test.module @@ -53,7 +53,7 @@ function layout_builder_test_preprocess_layout__twocol_section(&$vars): void { /** * Implements hook_module_implements_alter(). */ -function layout_builder_test_module_implements_alter(&$implementations, $hook) { +function layout_builder_test_module_implements_alter(&$implementations, $hook): void { if ($hook === 'system_breadcrumb_alter') { // Move our hook_system_breadcrumb_alter() implementation to run before // layout_builder_system_breadcrumb_alter(). diff --git a/core/modules/media_library/tests/modules/media_library_form_overwrite_test/media_library_form_overwrite_test.module b/core/modules/media_library/tests/modules/media_library_form_overwrite_test/media_library_form_overwrite_test.module index 0056e27a75af..baf6bbd247f4 100644 --- a/core/modules/media_library/tests/modules/media_library_form_overwrite_test/media_library_form_overwrite_test.module +++ b/core/modules/media_library/tests/modules/media_library_form_overwrite_test/media_library_form_overwrite_test.module @@ -9,6 +9,6 @@ use Drupal\media_library_form_overwrite_test\Form\TestAddForm; -function media_library_form_overwrite_test_media_source_info_alter(array &$sources) { +function media_library_form_overwrite_test_media_source_info_alter(array &$sources): void { $sources['image']['forms']['media_library_add'] = TestAddForm::class; } diff --git a/core/modules/navigation/navigation.module b/core/modules/navigation/navigation.module index 8dcdee642ef7..a2be21b65590 100644 --- a/core/modules/navigation/navigation.module +++ b/core/modules/navigation/navigation.module @@ -9,7 +9,7 @@ /** * Implements hook_module_implements_alter(). */ -function navigation_module_implements_alter(&$implementations, $hook) { +function navigation_module_implements_alter(&$implementations, $hook): void { if ($hook == 'page_top') { $group = $implementations['navigation']; unset($implementations['navigation']); diff --git a/core/modules/system/tests/modules/common_test/common_test.module b/core/modules/system/tests/modules/common_test/common_test.module index 526f3f40b8cf..b0a2df54e328 100644 --- a/core/modules/system/tests/modules/common_test/common_test.module +++ b/core/modules/system/tests/modules/common_test/common_test.module @@ -13,7 +13,7 @@ * Same as common_test_drupal_alter_alter(), but here, we verify that themes * can also alter and come last. */ -function olivero_drupal_alter_alter(&$data, &$arg2 = NULL, &$arg3 = NULL) { +function olivero_drupal_alter_alter(&$data, &$arg2 = NULL, &$arg3 = NULL): void { // Alter first argument. if (is_array($data)) { $data['foo'] .= ' theme'; @@ -46,7 +46,7 @@ function olivero_drupal_alter_alter(&$data, &$arg2 = NULL, &$arg3 = NULL) { * * @see block_drupal_alter_foo_alter() */ -function common_test_module_implements_alter(&$implementations, $hook) { +function common_test_module_implements_alter(&$implementations, $hook): void { // For // \Drupal::moduleHandler()->alter(array('drupal_alter', 'drupal_alter_foo'), ...), // make the block module implementations run after all the other modules. Note diff --git a/core/modules/system/tests/modules/deprecation_test/deprecation_test.module b/core/modules/system/tests/modules/deprecation_test/deprecation_test.module index 1d5b87a2ceb2..8ed02e6d0431 100644 --- a/core/modules/system/tests/modules/deprecation_test/deprecation_test.module +++ b/core/modules/system/tests/modules/deprecation_test/deprecation_test.module @@ -34,6 +34,6 @@ function deprecation_test_deprecated_hook($arg) { /** * Implements hook_deprecated_alter_alter(). */ -function deprecation_test_deprecated_alter_alter(&$data, $context1, $context2) { +function deprecation_test_deprecated_alter_alter(&$data, $context1, $context2): void { $data = [$context1, $context2]; } diff --git a/core/modules/system/tests/modules/module_test/module_test.module b/core/modules/system/tests/modules/module_test/module_test.module index fd8532103de5..6215067f9858 100644 --- a/core/modules/system/tests/modules/module_test/module_test.module +++ b/core/modules/system/tests/modules/module_test/module_test.module @@ -14,7 +14,7 @@ * * Manipulate module dependencies to test dependency chains. */ -function module_test_system_info_alter(&$info, Extension $file, $type) { +function module_test_system_info_alter(&$info, Extension $file, $type): void { if (\Drupal::state()->get('module_test.dependency') == 'missing dependency') { if ($file->getName() == 'dblog') { // Make dblog module depend on config. @@ -102,7 +102,7 @@ function module_test_modules_uninstalled($modules) { * @see module_test_altered_test_hook() * @see \Drupal\system\Tests\Module\ModuleImplementsAlterTest::testModuleImplementsAlter() */ -function module_test_module_implements_alter(&$implementations, $hook) { +function module_test_module_implements_alter(&$implementations, $hook): void { if ($hook === 'altered_test_hook') { // Add a hook implementation, that will be found in // module_test.implementation.inc. diff --git a/core/modules/system/tests/modules/unversioned_assets_test/unversioned_assets_test.module b/core/modules/system/tests/modules/unversioned_assets_test/unversioned_assets_test.module index 60826a1ade86..89d46002e97e 100644 --- a/core/modules/system/tests/modules/unversioned_assets_test/unversioned_assets_test.module +++ b/core/modules/system/tests/modules/unversioned_assets_test/unversioned_assets_test.module @@ -10,7 +10,7 @@ /** * Implements hook_library_info_build(). */ -function unversioned_assets_test_library_info_alter(&$libraries, $extension) { +function unversioned_assets_test_library_info_alter(&$libraries, $extension): void { if ($extension === 'system') { // Remove the version and provide an additional CSS file we can alter the // contents of . diff --git a/core/modules/system/tests/themes/test_theme/test_theme.theme b/core/modules/system/tests/themes/test_theme/test_theme.theme index 19c7695757c8..80214af02d0b 100644 --- a/core/modules/system/tests/themes/test_theme/test_theme.theme +++ b/core/modules/system/tests/themes/test_theme/test_theme.theme @@ -17,7 +17,7 @@ function test_theme_preprocess_twig_theme_test_php_variables(&$variables): void /** * Implements hook_element_info_alter(). */ -function test_theme_element_info_alter(&$info) { +function test_theme_element_info_alter(&$info): void { // Decrease the default size of textfields. if (isset($info['textfield']['#size'])) { $info['textfield']['#size'] = 40; @@ -27,7 +27,7 @@ function test_theme_element_info_alter(&$info) { /** * Implements hook_library_info_alter(). */ -function test_theme_library_info_alter(&$libraries, $extension) { +function test_theme_library_info_alter(&$libraries, $extension): void { if ($extension === 'test_theme') { $libraries['kitten']['js']['kittens.js'] = []; } @@ -40,14 +40,14 @@ function test_theme_library_info_alter(&$libraries, $extension) { * the alter hook invoked when the 'theme_test' module calls * \Drupal::moduleHandler->alter('theme_test_alter'). */ -function test_theme_theme_test_alter_alter(&$data) { +function test_theme_theme_test_alter_alter(&$data): void { $data = 'test_theme_theme_test_alter_alter was invoked'; } /** * Implements hook_theme_suggestions_alter(). */ -function test_theme_theme_suggestions_alter(array &$suggestions, array &$variables, $hook) { +function test_theme_theme_suggestions_alter(array &$suggestions, array &$variables, $hook): void { \Drupal::messenger()->addStatus(__FUNCTION__ . '() executed.'); // Theme alter hooks run after module alter hooks, so add this theme // suggestion to the beginning of the array so that the suggestion added by @@ -62,7 +62,7 @@ function test_theme_theme_suggestions_alter(array &$suggestions, array &$variabl /** * Implements hook_theme_suggestions_HOOK_alter(). */ -function test_theme_theme_suggestions_theme_test_suggestions_alter(array &$suggestions, array $variables) { +function test_theme_theme_suggestions_theme_test_suggestions_alter(array &$suggestions, array $variables): void { \Drupal::messenger()->addStatus(__FUNCTION__ . '() executed.'); // Theme alter hooks run after module alter hooks, so add this theme // suggestion to the beginning of the array so that the suggestion added by @@ -74,7 +74,7 @@ function test_theme_theme_suggestions_theme_test_suggestions_alter(array &$sugge /** * Implements hook_theme_suggestions_HOOK_alter(). */ -function test_theme_theme_suggestions_node_alter(array &$suggestions, array $variables) { +function test_theme_theme_suggestions_node_alter(array &$suggestions, array $variables): void { // Add an invalid suggestion to be tested. $suggestions[] = 'invalid_theme_suggestions'; \Drupal::messenger()->addStatus(__FUNCTION__ . '() executed.'); @@ -83,7 +83,7 @@ function test_theme_theme_suggestions_node_alter(array &$suggestions, array $var /** * Implements hook_theme_registry_alter(). */ -function test_theme_theme_registry_alter(&$registry) { +function test_theme_theme_registry_alter(&$registry): void { $registry['theme_test_template_test']['variables']['additional'] = 'value'; } diff --git a/core/modules/views_ui/tests/themes/views_ui_test_theme/views_ui_test_theme.theme b/core/modules/views_ui/tests/themes/views_ui_test_theme/views_ui_test_theme.theme index 14efd0a78082..8a5b82e0869b 100644 --- a/core/modules/views_ui/tests/themes/views_ui_test_theme/views_ui_test_theme.theme +++ b/core/modules/views_ui/tests/themes/views_ui_test_theme/views_ui_test_theme.theme @@ -12,13 +12,13 @@ /** * Implements hook_views_ui_display_tab_alter(). */ -function views_ui_test_theme_views_ui_display_tab_alter(&$build, ViewUI $view, $display_id) { +function views_ui_test_theme_views_ui_display_tab_alter(&$build, ViewUI $view, $display_id): void { $build['details']['top']['display_title']['#description'] = 'This is text added to the display edit form'; } /** * Implements hook_views_ui_display_top_alter(). */ -function views_ui_test_theme_views_ui_display_top_alter(&$build, ViewUI $view, $display_id) { +function views_ui_test_theme_views_ui_display_top_alter(&$build, ViewUI $view, $display_id): void { $build['tabs']['#suffix'] .= 'This is text added to the display tabs at the top'; } diff --git a/core/profiles/demo_umami/themes/umami/umami.theme b/core/profiles/demo_umami/themes/umami/umami.theme index d693eb14f070..e925c0616a4d 100644 --- a/core/profiles/demo_umami/themes/umami/umami.theme +++ b/core/profiles/demo_umami/themes/umami/umami.theme @@ -62,7 +62,7 @@ function umami_preprocess_block(&$variables): void { /** * Implements hook_theme_suggestions_HOOK_alter() for block templates. */ -function umami_theme_suggestions_block_alter(array &$suggestions, array $variables) { +function umami_theme_suggestions_block_alter(array &$suggestions, array $variables): void { // Block suggestions for content block bundles. if (isset($variables['elements']['content']['#block_content'])) { array_splice($suggestions, 1, 0, 'block__bundle__' . $variables['elements']['content']['#block_content']->bundle()); diff --git a/core/themes/claro/claro.theme b/core/themes/claro/claro.theme index 6015fdf976bb..896a065742f2 100644 --- a/core/themes/claro/claro.theme +++ b/core/themes/claro/claro.theme @@ -24,7 +24,7 @@ /** * Implements hook_theme_suggestions_HOOK_alter() for form_element. */ -function claro_theme_suggestions_form_element_alter(&$suggestions, $variables) { +function claro_theme_suggestions_form_element_alter(&$suggestions, $variables): void { if (!empty($variables['element']['#type'])) { $suggestions[] = 'form_element__' . $variables['element']['#type']; } @@ -33,7 +33,7 @@ function claro_theme_suggestions_form_element_alter(&$suggestions, $variables) { /** * Implements hook_theme_suggestions_HOOK_alter() for details. */ -function claro_theme_suggestions_details_alter(&$suggestions, $variables) { +function claro_theme_suggestions_details_alter(&$suggestions, $variables): void { if (!empty($variables['element']['#vertical_tab_item'])) { $suggestions[] = 'details__vertical_tabs'; } @@ -42,7 +42,7 @@ function claro_theme_suggestions_details_alter(&$suggestions, $variables) { /** * Implements hook_page_attachments_alter(). */ -function claro_page_attachments_alter(array &$attachments) { +function claro_page_attachments_alter(array &$attachments): void { $theme_path = \Drupal::request()->getBasePath() . '/' . \Drupal::service('extension.list.theme')->getPath('claro'); $query_string = \Drupal::service('asset.query_string')->get(); @@ -263,7 +263,7 @@ function claro_preprocess_menu_local_action(array &$variables): void { /** * Implements hook_element_info_alter(). */ -function claro_element_info_alter(&$type) { +function claro_element_info_alter(&$type): void { // Add a pre-render function that handles the sidebar of the node form. // @todo Refactor when https://www.drupal.org/node/3056089 is in. if (isset($type['container'])) { @@ -326,7 +326,7 @@ function claro_preprocess_text_format_wrapper(&$variables): void { /** * Implements hook_theme_registry_alter(). */ -function claro_theme_registry_alter(&$theme_registry) { +function claro_theme_registry_alter(&$theme_registry): void { if (!empty($theme_registry['admin_block_content'])) { $theme_registry['admin_block_content']['variables']['attributes'] = []; } @@ -356,7 +356,7 @@ function claro_preprocess_maintenance_page(&$variables): void { /** * Implements hook_theme_suggestions_maintenance_page_alter(). */ -function claro_theme_suggestions_maintenance_page_alter(&$suggestions) { +function claro_theme_suggestions_maintenance_page_alter(&$suggestions): void { try { $is_front = \Drupal::service('path.matcher')->isFrontPage(); } @@ -761,7 +761,7 @@ function claro_form_media_form_alter(&$form, FormStateInterface $form_state): vo /** * Implements hook_views_ui_display_top_alter(). */ -function claro_views_ui_display_top_alter(&$element) { +function claro_views_ui_display_top_alter(&$element): void { // @todo Remove this after https://www.drupal.org/node/3051605 has been // solved. $element['tabs']['#prefix'] = preg_replace('/(class="(.+\s)?)tabs(\s.+"|")/', '$1views-tabs$3', $element['tabs']['#prefix']); @@ -806,7 +806,7 @@ function claro_views_ui_display_top_alter(&$element) { /** * Implements hook_views_ui_display_tab_alter(). */ -function claro_views_ui_display_tab_alter(&$element) { +function claro_views_ui_display_tab_alter(&$element): void { // We process the dropbutton-like element on views edit form's // display settings top section. // @@ -1802,7 +1802,7 @@ function claro_preprocess_toolbar(&$variables, $hook, $info): void { * * @see system_library_info_alter() */ -function claro_system_module_invoked_library_info_alter(&$libraries, $extension) { +function claro_system_module_invoked_library_info_alter(&$libraries, $extension): void { if ($extension === 'toolbar') { $claro_info = \Drupal::service('theme_handler')->listInfo()['claro']->info; $path_prefix = '/core/themes/claro/'; @@ -1833,7 +1833,7 @@ function claro_system_module_invoked_library_info_alter(&$libraries, $extension) * * @see system_theme_registry_alter() */ -function claro_system_module_invoked_theme_registry_alter(array &$theme_registry) { +function claro_system_module_invoked_theme_registry_alter(array &$theme_registry): void { foreach (['toolbar', 'menu__toolbar'] as $registry_item) { if (isset($theme_registry[$registry_item])) { $theme_registry[$registry_item]['path'] = 'core/themes/claro/templates/navigation'; diff --git a/core/themes/olivero/olivero.theme b/core/themes/olivero/olivero.theme index 8742715b2f81..2f7e5d8d3350 100644 --- a/core/themes/olivero/olivero.theme +++ b/core/themes/olivero/olivero.theme @@ -162,7 +162,7 @@ function olivero_preprocess_block(&$variables): void { /** * Implements hook_theme_suggestions_HOOK_alter() for menu. */ -function olivero_theme_suggestions_menu_alter(&$suggestions, array $variables) { +function olivero_theme_suggestions_menu_alter(&$suggestions, array $variables): void { if (isset($variables['attributes']['region'])) { $suggestions[] = 'menu__' . $variables['attributes']['region']; } @@ -183,7 +183,7 @@ function olivero_preprocess_menu(&$variables): void { /** * Implements hook_theme_suggestions_HOOK_alter() for form templates. */ -function olivero_theme_suggestions_form_alter(array &$suggestions, array $variables) { +function olivero_theme_suggestions_form_alter(array &$suggestions, array $variables): void { if ($variables['element']['#form_id'] === 'search_block_form') { $suggestions[] = 'form__search_block_form'; } @@ -217,7 +217,7 @@ function olivero_form_alter(&$form, FormStateInterface $form_state, $form_id): v /** * Implements hook_theme_suggestions_HOOK_alter() for block(). */ -function olivero_theme_suggestions_block_alter(&$suggestions, array $variables) { +function olivero_theme_suggestions_block_alter(&$suggestions, array $variables): void { if (!empty($variables['elements']['#id'])) { /** @var \Drupal\block\BlockInterface $block */ @@ -480,7 +480,7 @@ function olivero_preprocess_fieldset(&$variables): void { /** * Implements hook_theme_suggestions_HOOK_alter(). */ -function olivero_theme_suggestions_user_alter(&$suggestions, $variables) { +function olivero_theme_suggestions_user_alter(&$suggestions, $variables): void { $suggestions[] = 'user__' . $variables['elements']['#view_mode']; } @@ -545,7 +545,7 @@ function olivero_preprocess_field__comment(&$variables): void { /** * Implements hook_element_info_alter(). */ -function olivero_element_info_alter(&$info) { +function olivero_element_info_alter(&$info): void { if (array_key_exists('text_format', $info)) { $info['text_format']['#pre_render'][] = [OliveroPreRender::class, 'textFormat']; } -- GitLab