From 22e2a1285afe3504a865fd43df6d19671f582399 Mon Sep 17 00:00:00 2001
From: Dave Long <dave@longwaveconsulting.com>
Date: Thu, 22 Aug 2024 18:27:50 +0100
Subject: [PATCH] Issue #3458422 by mstrelan, smustgrave: Add string return
 typehints to protected test helper methods

---
 .../tests/src/Functional/ConfigTranslationInstallTest.php | 2 +-
 .../datetime/tests/src/Functional/DateTimeFieldTest.php   | 2 +-
 .../datetime/tests/src/Functional/DateTimeWidgetTest.php  | 2 +-
 .../tests/src/Functional/DateRangeFieldTest.php           | 2 +-
 .../src/HelpTestTwigNodeVisitor.php                       | 2 +-
 .../help/tests/src/Functional/HelpTopicsSyntaxTest.php    | 2 +-
 .../image/tests/src/Functional/ImageDimensionsTest.php    | 2 +-
 .../tests/src/Functional/BaseFieldOverrideTest.php        | 2 +-
 .../jsonapi/tests/src/Functional/ContactFormTest.php      | 2 +-
 core/modules/jsonapi/tests/src/Functional/EditorTest.php  | 2 +-
 .../tests/src/Functional/EntityFormDisplayTest.php        | 2 +-
 .../tests/src/Functional/EntityTestMapFieldTest.php       | 2 +-
 .../tests/src/Functional/EntityViewDisplayTest.php        | 2 +-
 .../jsonapi/tests/src/Functional/FieldConfigTest.php      | 2 +-
 .../tests/src/Functional/FieldStorageConfigTest.php       | 2 +-
 .../jsonapi/tests/src/Functional/FileUploadTest.php       | 2 +-
 core/modules/jsonapi/tests/src/Functional/NodeTest.php    | 2 +-
 .../modules/jsonapi/tests/src/Functional/NodeTypeTest.php | 2 +-
 .../tests/src/Functional/ResourceResponseTestTrait.php    | 4 ++--
 .../tests/src/Functional/RestJsonApiUnsupported.php       | 2 +-
 .../modules/jsonapi/tests/src/Functional/ShortcutTest.php | 2 +-
 .../Plugin/SectionStorage/SimpleConfigSectionStorage.php  | 2 +-
 .../FunctionalJavascript/InlineBlockPrivateFilesTest.php  | 2 +-
 .../src/FunctionalJavascript/LayoutBuilderOptInTest.php   | 2 +-
 core/modules/link/tests/src/Functional/LinkFieldTest.php  | 2 +-
 .../src/Functional/LocaleNonInteractiveDevInstallTest.php | 2 +-
 .../src/Functional/LocaleNonInteractiveInstallTest.php    | 2 +-
 core/modules/media/tests/src/Traits/OEmbedTestTrait.php   | 4 ++--
 .../tests/src/Functional/CredentialFormTest.php           | 2 +-
 .../tests/src/Functional/MigrateUpgradeFormStepsTest.php  | 2 +-
 .../tests/src/Functional/SourceProviderTest.php           | 2 +-
 .../tests/src/Functional/d6/IdConflictTest.php            | 2 +-
 .../src/Functional/d6/MultilingualReviewPageTest.php      | 2 +-
 .../src/Functional/d6/NoMultilingualReviewPageTest.php    | 2 +-
 .../tests/src/Functional/d6/NodeClassicTest.php           | 2 +-
 .../tests/src/Functional/d6/Upgrade6Test.php              | 2 +-
 .../tests/src/Functional/d7/DoubleSlashTest.php           | 2 +-
 .../tests/src/Functional/d7/FilePathTest.php              | 2 +-
 .../tests/src/Functional/d7/IdConflictTest.php            | 2 +-
 .../src/Functional/d7/MultilingualReviewPageTest.php      | 2 +-
 .../src/Functional/d7/NoMultilingualReviewPageTest.php    | 2 +-
 .../tests/src/Functional/d7/Upgrade7Test.php              | 2 +-
 .../node/tests/src/Functional/NodeTranslationUITest.php   | 2 +-
 .../path/tests/src/Unit/Field/PathFieldDefinitionTest.php | 2 +-
 .../tests/src/Functional/SettingsTrayTest.php             | 2 +-
 .../src/Functional/Form/FormStoragePageCacheTest.php      | 2 +-
 .../tests/src/Functional/Session/SessionHttpsTest.php     | 8 ++++----
 .../src/Functional/System/SitesDirectoryHardeningTest.php | 2 +-
 .../tests/src/Functional/UserRegistrationRestTest.php     | 2 +-
 .../views/tests/src/Kernel/Plugin/StyleMappingTest.php    | 2 +-
 .../tests/src/Functional/UmamiMultilingualInstallTest.php | 2 +-
 .../Drupal/FunctionalJavascriptTests/JSWebAssert.php      | 2 +-
 .../FunctionalJavascriptTests/PerformanceTestBase.php     | 2 +-
 .../Installer/DistributionProfileTranslationQueryTest.php | 2 +-
 .../Installer/DistributionProfileTranslationTest.php      | 2 +-
 .../Installer/InstallerExistingConfigMultilingualTest.php | 2 +-
 .../Installer/InstallerExistingConfigNoConfigTest.php     | 2 +-
 .../Installer/InstallerExistingConfigNoSystemSiteTest.php | 2 +-
 .../InstallerExistingConfigProfileHookInstall.php         | 2 +-
 ...stallerExistingConfigSyncDirectoryMultilingualTest.php | 4 ++--
 ...allerExistingConfigSyncDirectoryProfileHookInstall.php | 2 +-
 ...llerExistingConfigSyncDirectoryProfileMismatchTest.php | 2 +-
 .../Installer/InstallerExistingConfigTest.php             | 2 +-
 ...allerTranslationMultipleLanguageNonInteractiveTest.php | 2 +-
 .../InstallerTranslationMultipleLanguageTest.php          | 2 +-
 .../Installer/InstallerTranslationQueryTest.php           | 2 +-
 .../Installer/InstallerTranslationTest.php                | 2 +-
 .../Entity/EntityDecoupledTranslationRevisionsTest.php    | 2 +-
 core/tests/Drupal/Tests/BrowserHtmlDebugTrait.php         | 2 +-
 .../DependencyInjection/Dumper/PhpArrayDumperTest.php     | 4 ++--
 .../DependencyInjection/PhpArrayContainerTest.php         | 4 ++--
 core/tests/Drupal/Tests/Component/Graph/GraphTest.php     | 2 +-
 .../Drupal/Tests/Composer/Plugin/Scaffold/ExecTrait.php   | 2 +-
 .../Plugin/Scaffold/Functional/ManageGitIgnoreTest.php    | 2 +-
 .../Composer/Plugin/Scaffold/Functional/ScaffoldTest.php  | 2 +-
 .../Plugin/Scaffold/Functional/ScaffoldUpgradeTest.php    | 2 +-
 core/tests/Drupal/Tests/ComposerIntegrationTest.php       | 2 +-
 core/tests/Drupal/Tests/Core/Cache/VariationCacheTest.php | 2 +-
 .../Drupal/Tests/Core/Entity/EntityTypeManagerTest.php    | 2 +-
 core/tests/Drupal/Tests/Core/Entity/EntityTypeTest.php    | 2 +-
 .../Tests/Core/Plugin/FilteredPluginManagerTraitTest.php  | 2 +-
 core/tests/Drupal/Tests/RandomGeneratorTrait.php          | 2 +-
 .../Drupal/Tests/Scripts/TestSiteApplicationTest.php      | 4 ++--
 core/tests/Drupal/Tests/TestRequirementsTrait.php         | 2 +-
 core/tests/Drupal/Tests/UiHelperTrait.php                 | 2 +-
 85 files changed, 94 insertions(+), 94 deletions(-)

diff --git a/core/modules/config_translation/tests/src/Functional/ConfigTranslationInstallTest.php b/core/modules/config_translation/tests/src/Functional/ConfigTranslationInstallTest.php
index 5f454f6dacb3..87bddc258e8c 100644
--- a/core/modules/config_translation/tests/src/Functional/ConfigTranslationInstallTest.php
+++ b/core/modules/config_translation/tests/src/Functional/ConfigTranslationInstallTest.php
@@ -48,7 +48,7 @@ protected function setUpLanguage() {
    * @return string
    *   Contents for the test .po file.
    */
-  protected function getPo($langcode) {
+  protected function getPo($langcode): string {
     return <<<PO
 msgid ""
 msgstr ""
diff --git a/core/modules/datetime/tests/src/Functional/DateTimeFieldTest.php b/core/modules/datetime/tests/src/Functional/DateTimeFieldTest.php
index 5d788a4e7632..782b73a0d753 100644
--- a/core/modules/datetime/tests/src/Functional/DateTimeFieldTest.php
+++ b/core/modules/datetime/tests/src/Functional/DateTimeFieldTest.php
@@ -36,7 +36,7 @@ class DateTimeFieldTest extends DateTestBase {
   /**
    * {@inheritdoc}
    */
-  protected function getTestFieldType() {
+  protected function getTestFieldType(): string {
     return 'datetime';
   }
 
diff --git a/core/modules/datetime/tests/src/Functional/DateTimeWidgetTest.php b/core/modules/datetime/tests/src/Functional/DateTimeWidgetTest.php
index a008e4bff92c..c920e258ed7c 100644
--- a/core/modules/datetime/tests/src/Functional/DateTimeWidgetTest.php
+++ b/core/modules/datetime/tests/src/Functional/DateTimeWidgetTest.php
@@ -29,7 +29,7 @@ class DateTimeWidgetTest extends DateTestBase {
   /**
    * {@inheritdoc}
    */
-  protected function getTestFieldType() {
+  protected function getTestFieldType(): string {
     return 'datetime';
   }
 
diff --git a/core/modules/datetime_range/tests/src/Functional/DateRangeFieldTest.php b/core/modules/datetime_range/tests/src/Functional/DateRangeFieldTest.php
index b6506ac691ca..8071ed02b7e0 100644
--- a/core/modules/datetime_range/tests/src/Functional/DateRangeFieldTest.php
+++ b/core/modules/datetime_range/tests/src/Functional/DateRangeFieldTest.php
@@ -49,7 +49,7 @@ class DateRangeFieldTest extends DateTestBase {
   /**
    * {@inheritdoc}
    */
-  protected function getTestFieldType() {
+  protected function getTestFieldType(): string {
     return 'daterange';
   }
 
diff --git a/core/modules/help/tests/modules/help_topics_twig_tester/src/HelpTestTwigNodeVisitor.php b/core/modules/help/tests/modules/help_topics_twig_tester/src/HelpTestTwigNodeVisitor.php
index af323effb974..85d54711190b 100644
--- a/core/modules/help/tests/modules/help_topics_twig_tester/src/HelpTestTwigNodeVisitor.php
+++ b/core/modules/help/tests/modules/help_topics_twig_tester/src/HelpTestTwigNodeVisitor.php
@@ -108,7 +108,7 @@ public function getPriority() {
    * @return string
    *   Text in the node.
    */
-  protected function extractText(TwigNodeTrans $node) {
+  protected function extractText(TwigNodeTrans $node): string {
     // Extract the singular/body and optional plural text from the
     // TwigNodeTrans object.
     $bodies = $node->getNode('body');
diff --git a/core/modules/help/tests/src/Functional/HelpTopicsSyntaxTest.php b/core/modules/help/tests/src/Functional/HelpTopicsSyntaxTest.php
index 53a42d82628c..1ae1fab8c633 100644
--- a/core/modules/help/tests/src/Functional/HelpTopicsSyntaxTest.php
+++ b/core/modules/help/tests/src/Functional/HelpTopicsSyntaxTest.php
@@ -335,7 +335,7 @@ protected function listDirectories($type) {
    * @return string
    *   The rendered topic.
    */
-  protected function renderHelpTopic(string $content, string $manner) {
+  protected function renderHelpTopic(string $content, string $manner): string {
     // Set up the special state variables for rendering.
     HelpTestTwigNodeVisitor::setStateValue('manner', $manner);
     HelpTestTwigNodeVisitor::setStateValue('max_chunk', -1);
diff --git a/core/modules/image/tests/src/Functional/ImageDimensionsTest.php b/core/modules/image/tests/src/Functional/ImageDimensionsTest.php
index dbf6ee77aa20..c709bd81ce01 100644
--- a/core/modules/image/tests/src/Functional/ImageDimensionsTest.php
+++ b/core/modules/image/tests/src/Functional/ImageDimensionsTest.php
@@ -305,7 +305,7 @@ public function testImageDimensions(): void {
    * method and pass each time a fresh array so that $variables won't get
    * altered and the element is re-rendered each time.
    */
-  protected function getImageTag($variables) {
+  protected function getImageTag($variables): string {
     return str_replace("\n", '', (string) \Drupal::service('renderer')->renderRoot($variables));
   }
 
diff --git a/core/modules/jsonapi/tests/src/Functional/BaseFieldOverrideTest.php b/core/modules/jsonapi/tests/src/Functional/BaseFieldOverrideTest.php
index 08ed9b77f934..9574344858dc 100644
--- a/core/modules/jsonapi/tests/src/Functional/BaseFieldOverrideTest.php
+++ b/core/modules/jsonapi/tests/src/Functional/BaseFieldOverrideTest.php
@@ -133,7 +133,7 @@ protected function getPostDocument(): array {
   /**
    * {@inheritdoc}
    */
-  protected function getExpectedUnauthorizedAccessMessage($method) {
+  protected function getExpectedUnauthorizedAccessMessage($method): string {
     return "The 'administer node fields' permission is required.";
   }
 
diff --git a/core/modules/jsonapi/tests/src/Functional/ContactFormTest.php b/core/modules/jsonapi/tests/src/Functional/ContactFormTest.php
index f805124440f2..1ef3a4f06ef9 100644
--- a/core/modules/jsonapi/tests/src/Functional/ContactFormTest.php
+++ b/core/modules/jsonapi/tests/src/Functional/ContactFormTest.php
@@ -121,7 +121,7 @@ protected function getPostDocument(): array {
   /**
    * {@inheritdoc}
    */
-  protected function getExpectedUnauthorizedAccessMessage($method) {
+  protected function getExpectedUnauthorizedAccessMessage($method): string {
     return "The 'access site-wide contact form' permission is required.";
   }
 
diff --git a/core/modules/jsonapi/tests/src/Functional/EditorTest.php b/core/modules/jsonapi/tests/src/Functional/EditorTest.php
index 4a0e1a1cf082..7862c2627041 100644
--- a/core/modules/jsonapi/tests/src/Functional/EditorTest.php
+++ b/core/modules/jsonapi/tests/src/Functional/EditorTest.php
@@ -168,7 +168,7 @@ protected function getPostDocument(): array {
   /**
    * {@inheritdoc}
    */
-  protected function getExpectedUnauthorizedAccessMessage($method) {
+  protected function getExpectedUnauthorizedAccessMessage($method): string {
     return "The 'administer filters' permission is required.";
   }
 
diff --git a/core/modules/jsonapi/tests/src/Functional/EntityFormDisplayTest.php b/core/modules/jsonapi/tests/src/Functional/EntityFormDisplayTest.php
index f0fd9421fa56..9fe865e18e6e 100644
--- a/core/modules/jsonapi/tests/src/Functional/EntityFormDisplayTest.php
+++ b/core/modules/jsonapi/tests/src/Functional/EntityFormDisplayTest.php
@@ -182,7 +182,7 @@ protected function getPostDocument(): array {
   /**
    * {@inheritdoc}
    */
-  protected function getExpectedUnauthorizedAccessMessage($method) {
+  protected function getExpectedUnauthorizedAccessMessage($method): string {
     return "The 'administer node form display' permission is required.";
   }
 
diff --git a/core/modules/jsonapi/tests/src/Functional/EntityTestMapFieldTest.php b/core/modules/jsonapi/tests/src/Functional/EntityTestMapFieldTest.php
index 92f938389867..1572c694438f 100644
--- a/core/modules/jsonapi/tests/src/Functional/EntityTestMapFieldTest.php
+++ b/core/modules/jsonapi/tests/src/Functional/EntityTestMapFieldTest.php
@@ -155,7 +155,7 @@ protected function getPostDocument(): array {
   /**
    * {@inheritdoc}
    */
-  protected function getExpectedUnauthorizedAccessMessage($method) {
+  protected function getExpectedUnauthorizedAccessMessage($method): string {
     return "The 'administer entity_test content' permission is required.";
   }
 
diff --git a/core/modules/jsonapi/tests/src/Functional/EntityViewDisplayTest.php b/core/modules/jsonapi/tests/src/Functional/EntityViewDisplayTest.php
index 53ad8f4aa148..ef94743f6464 100644
--- a/core/modules/jsonapi/tests/src/Functional/EntityViewDisplayTest.php
+++ b/core/modules/jsonapi/tests/src/Functional/EntityViewDisplayTest.php
@@ -135,7 +135,7 @@ protected function getPostDocument(): array {
   /**
    * {@inheritdoc}
    */
-  protected function getExpectedUnauthorizedAccessMessage($method) {
+  protected function getExpectedUnauthorizedAccessMessage($method): string {
     return "The 'administer node display' permission is required.";
   }
 
diff --git a/core/modules/jsonapi/tests/src/Functional/FieldConfigTest.php b/core/modules/jsonapi/tests/src/Functional/FieldConfigTest.php
index 32d5aa626cf1..69178104ebf8 100644
--- a/core/modules/jsonapi/tests/src/Functional/FieldConfigTest.php
+++ b/core/modules/jsonapi/tests/src/Functional/FieldConfigTest.php
@@ -142,7 +142,7 @@ protected function getPostDocument(): array {
   /**
    * {@inheritdoc}
    */
-  protected function getExpectedUnauthorizedAccessMessage($method) {
+  protected function getExpectedUnauthorizedAccessMessage($method): string {
     return "The 'administer node fields' permission is required.";
   }
 
diff --git a/core/modules/jsonapi/tests/src/Functional/FieldStorageConfigTest.php b/core/modules/jsonapi/tests/src/Functional/FieldStorageConfigTest.php
index 329ffdd5efbd..36c1a0b40299 100644
--- a/core/modules/jsonapi/tests/src/Functional/FieldStorageConfigTest.php
+++ b/core/modules/jsonapi/tests/src/Functional/FieldStorageConfigTest.php
@@ -121,7 +121,7 @@ protected function getPostDocument(): array {
   /**
    * {@inheritdoc}
    */
-  protected function getExpectedUnauthorizedAccessMessage($method) {
+  protected function getExpectedUnauthorizedAccessMessage($method): string {
     return "The 'administer node fields' permission is required.";
   }
 
diff --git a/core/modules/jsonapi/tests/src/Functional/FileUploadTest.php b/core/modules/jsonapi/tests/src/Functional/FileUploadTest.php
index b40e2b2b9c9d..023de93b84b4 100644
--- a/core/modules/jsonapi/tests/src/Functional/FileUploadTest.php
+++ b/core/modules/jsonapi/tests/src/Functional/FileUploadTest.php
@@ -722,7 +722,7 @@ public function testFileUploadNoConfiguration(): void {
   /**
    * {@inheritdoc}
    */
-  protected function getExpectedUnauthorizedAccessMessage($method) {
+  protected function getExpectedUnauthorizedAccessMessage($method): string {
     switch ($method) {
       case 'GET':
         return "The current user is not allowed to view this relationship. The 'view test entity' permission is required.";
diff --git a/core/modules/jsonapi/tests/src/Functional/NodeTest.php b/core/modules/jsonapi/tests/src/Functional/NodeTest.php
index a154b62aeb7c..616f8da8e0f3 100644
--- a/core/modules/jsonapi/tests/src/Functional/NodeTest.php
+++ b/core/modules/jsonapi/tests/src/Functional/NodeTest.php
@@ -262,7 +262,7 @@ protected function getPostDocument(): array {
   /**
    * {@inheritdoc}
    */
-  protected function getExpectedUnauthorizedAccessMessage($method) {
+  protected function getExpectedUnauthorizedAccessMessage($method): string {
     switch ($method) {
       case 'GET':
       case 'POST':
diff --git a/core/modules/jsonapi/tests/src/Functional/NodeTypeTest.php b/core/modules/jsonapi/tests/src/Functional/NodeTypeTest.php
index d4ee2d3d423e..733cbb107ddc 100644
--- a/core/modules/jsonapi/tests/src/Functional/NodeTypeTest.php
+++ b/core/modules/jsonapi/tests/src/Functional/NodeTypeTest.php
@@ -115,7 +115,7 @@ protected function getPostDocument(): array {
   /**
    * {@inheritdoc}
    */
-  protected function getExpectedUnauthorizedAccessMessage($method) {
+  protected function getExpectedUnauthorizedAccessMessage($method): string {
     return "The 'access content' permission is required.";
   }
 
diff --git a/core/modules/jsonapi/tests/src/Functional/ResourceResponseTestTrait.php b/core/modules/jsonapi/tests/src/Functional/ResourceResponseTestTrait.php
index d1b90c025ec4..b2954987cec0 100644
--- a/core/modules/jsonapi/tests/src/Functional/ResourceResponseTestTrait.php
+++ b/core/modules/jsonapi/tests/src/Functional/ResourceResponseTestTrait.php
@@ -398,7 +398,7 @@ protected static function getResourceLink(array $resource_identifier) {
    * @return string
    *   The relationship link.
    */
-  protected static function getRelationshipLink(array $resource_identifier, $relationship_field_name) {
+  protected static function getRelationshipLink(array $resource_identifier, $relationship_field_name): string {
     return static::getResourceLink($resource_identifier) . "/relationships/$relationship_field_name";
   }
 
@@ -413,7 +413,7 @@ protected static function getRelationshipLink(array $resource_identifier, $relat
    * @return string
    *   The related resource link.
    */
-  protected static function getRelatedLink(array $resource_identifier, $relationship_field_name) {
+  protected static function getRelatedLink(array $resource_identifier, $relationship_field_name): string {
     return static::getResourceLink($resource_identifier) . "/$relationship_field_name";
   }
 
diff --git a/core/modules/jsonapi/tests/src/Functional/RestJsonApiUnsupported.php b/core/modules/jsonapi/tests/src/Functional/RestJsonApiUnsupported.php
index c07992ca8013..fdff2e648499 100644
--- a/core/modules/jsonapi/tests/src/Functional/RestJsonApiUnsupported.php
+++ b/core/modules/jsonapi/tests/src/Functional/RestJsonApiUnsupported.php
@@ -118,7 +118,7 @@ protected function assertNormalizationEdgeCases($method, Url $url, array $reques
   /**
    * {@inheritdoc}
    */
-  protected function getExpectedUnauthorizedAccessMessage($method) {
+  protected function getExpectedUnauthorizedAccessMessage($method): string {
     return '';
   }
 
diff --git a/core/modules/jsonapi/tests/src/Functional/ShortcutTest.php b/core/modules/jsonapi/tests/src/Functional/ShortcutTest.php
index e5e9aed44366..a5e334833c69 100644
--- a/core/modules/jsonapi/tests/src/Functional/ShortcutTest.php
+++ b/core/modules/jsonapi/tests/src/Functional/ShortcutTest.php
@@ -152,7 +152,7 @@ protected function getPostDocument(): array {
   /**
    * {@inheritdoc}
    */
-  protected function getExpectedUnauthorizedAccessMessage($method) {
+  protected function getExpectedUnauthorizedAccessMessage($method): string {
     return "The shortcut set must be the currently displayed set for the user and the user must have 'access shortcuts' AND 'customize shortcut links' permissions.";
   }
 
diff --git a/core/modules/layout_builder/tests/modules/layout_builder_test/src/Plugin/SectionStorage/SimpleConfigSectionStorage.php b/core/modules/layout_builder/tests/modules/layout_builder_test/src/Plugin/SectionStorage/SimpleConfigSectionStorage.php
index 549aa1c25044..8004c121b047 100644
--- a/core/modules/layout_builder/tests/modules/layout_builder_test/src/Plugin/SectionStorage/SimpleConfigSectionStorage.php
+++ b/core/modules/layout_builder/tests/modules/layout_builder_test/src/Plugin/SectionStorage/SimpleConfigSectionStorage.php
@@ -95,7 +95,7 @@ public function label() {
   /**
    * Returns the name to be used to store in the config system.
    */
-  protected function getConfigName() {
+  protected function getConfigName(): string {
     return 'layout_builder_test.' . $this->getStorageType() . '.' . $this->getStorageId();
   }
 
diff --git a/core/modules/layout_builder/tests/src/FunctionalJavascript/InlineBlockPrivateFilesTest.php b/core/modules/layout_builder/tests/src/FunctionalJavascript/InlineBlockPrivateFilesTest.php
index a006aa29d6a9..570bdee7a135 100644
--- a/core/modules/layout_builder/tests/src/FunctionalJavascript/InlineBlockPrivateFilesTest.php
+++ b/core/modules/layout_builder/tests/src/FunctionalJavascript/InlineBlockPrivateFilesTest.php
@@ -258,7 +258,7 @@ protected function getFileHrefAccessibleOnNode(FileInterface $file): string {
    * @return string
    *   The text secret.
    */
-  protected function getFileSecret(FileInterface $file) {
+  protected function getFileSecret(FileInterface $file): string {
     return "The secret in {$file->label()}";
   }
 
diff --git a/core/modules/layout_builder/tests/src/FunctionalJavascript/LayoutBuilderOptInTest.php b/core/modules/layout_builder/tests/src/FunctionalJavascript/LayoutBuilderOptInTest.php
index e0664917c554..f5e106cfc9ac 100644
--- a/core/modules/layout_builder/tests/src/FunctionalJavascript/LayoutBuilderOptInTest.php
+++ b/core/modules/layout_builder/tests/src/FunctionalJavascript/LayoutBuilderOptInTest.php
@@ -172,7 +172,7 @@ public function testDefaultValues(): void {
    * @return string
    *   The path.
    */
-  protected function getPathForFieldBlock($entity_type_id, $bundle, $view_mode, $field_name) {
+  protected function getPathForFieldBlock($entity_type_id, $bundle, $view_mode, $field_name): string {
     $delta = 0;
     /** @var \Drupal\layout_builder\Entity\LayoutEntityDisplayInterface $display */
     $display = $this->container->get('entity_type.manager')->getStorage('entity_view_display')->load("$entity_type_id.$bundle.$view_mode");
diff --git a/core/modules/link/tests/src/Functional/LinkFieldTest.php b/core/modules/link/tests/src/Functional/LinkFieldTest.php
index c619a772ad4e..5def40709141 100644
--- a/core/modules/link/tests/src/Functional/LinkFieldTest.php
+++ b/core/modules/link/tests/src/Functional/LinkFieldTest.php
@@ -1056,7 +1056,7 @@ public function testNoLinkUri(): void {
    * @return string
    *   The rendered HTML output.
    */
-  protected function renderTestEntity($id, $view_mode = 'full', $reset = TRUE) {
+  protected function renderTestEntity($id, $view_mode = 'full', $reset = TRUE): string {
     if ($reset) {
       $this->container->get('entity_type.manager')->getStorage('entity_test')->resetCache([$id]);
     }
diff --git a/core/modules/locale/tests/src/Functional/LocaleNonInteractiveDevInstallTest.php b/core/modules/locale/tests/src/Functional/LocaleNonInteractiveDevInstallTest.php
index 328122afaf2b..af7b96a4f434 100644
--- a/core/modules/locale/tests/src/Functional/LocaleNonInteractiveDevInstallTest.php
+++ b/core/modules/locale/tests/src/Functional/LocaleNonInteractiveDevInstallTest.php
@@ -19,7 +19,7 @@ class LocaleNonInteractiveDevInstallTest extends LocaleNonInteractiveInstallTest
   /**
    * {@inheritdoc}
    */
-  protected function getVersionStringToTest() {
+  protected function getVersionStringToTest(): string {
     include_once $this->root . '/core/includes/install.core.inc';
     $version = _install_get_version_info(\Drupal::VERSION);
     return $version['major'] . '.' . $version['minor'] . '.x';
diff --git a/core/modules/locale/tests/src/Functional/LocaleNonInteractiveInstallTest.php b/core/modules/locale/tests/src/Functional/LocaleNonInteractiveInstallTest.php
index 43761ced2626..41f55ad80dfb 100644
--- a/core/modules/locale/tests/src/Functional/LocaleNonInteractiveInstallTest.php
+++ b/core/modules/locale/tests/src/Functional/LocaleNonInteractiveInstallTest.php
@@ -32,7 +32,7 @@ protected function setUp(): void {
    * @return string
    *   The version string to test, for example, '8.0.0' or '8.6.x'.
    */
-  protected function getVersionStringToTest() {
+  protected function getVersionStringToTest(): string {
     include_once $this->root . '/core/includes/install.core.inc';
     $version = _install_get_version_info(\Drupal::VERSION);
     return $version['major'] . '.0.0';
diff --git a/core/modules/media/tests/src/Traits/OEmbedTestTrait.php b/core/modules/media/tests/src/Traits/OEmbedTestTrait.php
index 0219be2007fc..273b2513301a 100644
--- a/core/modules/media/tests/src/Traits/OEmbedTestTrait.php
+++ b/core/modules/media/tests/src/Traits/OEmbedTestTrait.php
@@ -18,7 +18,7 @@ trait OEmbedTestTrait {
    *
    * @return string
    */
-  protected function getFixturesDirectory() {
+  protected function getFixturesDirectory(): string {
     return \Drupal::service('extension.list.module')->getPath('media') . '/tests/fixtures/oembed';
   }
 
@@ -27,7 +27,7 @@ protected function getFixturesDirectory() {
    *
    * @return string
    */
-  protected function getFixturesUrl() {
+  protected function getFixturesUrl(): string {
     return $this->baseUrl . '/' . $this->getFixturesDirectory();
   }
 
diff --git a/core/modules/migrate_drupal_ui/tests/src/Functional/CredentialFormTest.php b/core/modules/migrate_drupal_ui/tests/src/Functional/CredentialFormTest.php
index b9fa3c71c9da..d271652bffbf 100644
--- a/core/modules/migrate_drupal_ui/tests/src/Functional/CredentialFormTest.php
+++ b/core/modules/migrate_drupal_ui/tests/src/Functional/CredentialFormTest.php
@@ -102,7 +102,7 @@ public static function providerCredentialForm() {
   /**
    * {@inheritdoc}
    */
-  protected function getSourceBasePath() {
+  protected function getSourceBasePath(): string {
     $version = $this->getLegacyDrupalVersion($this->sourceDatabase);
     return __DIR__ . '/d' . $version . '/files';
   }
diff --git a/core/modules/migrate_drupal_ui/tests/src/Functional/MigrateUpgradeFormStepsTest.php b/core/modules/migrate_drupal_ui/tests/src/Functional/MigrateUpgradeFormStepsTest.php
index 2dfab8159c78..481be8709523 100644
--- a/core/modules/migrate_drupal_ui/tests/src/Functional/MigrateUpgradeFormStepsTest.php
+++ b/core/modules/migrate_drupal_ui/tests/src/Functional/MigrateUpgradeFormStepsTest.php
@@ -41,7 +41,7 @@ protected function setUp(): void {
   /**
    * {@inheritdoc}
    */
-  protected function getSourceBasePath() {
+  protected function getSourceBasePath(): string {
     return __DIR__ . '/files';
   }
 
diff --git a/core/modules/migrate_drupal_ui/tests/src/Functional/SourceProviderTest.php b/core/modules/migrate_drupal_ui/tests/src/Functional/SourceProviderTest.php
index ec2bc9ec8c86..dcbb3cda42c9 100644
--- a/core/modules/migrate_drupal_ui/tests/src/Functional/SourceProviderTest.php
+++ b/core/modules/migrate_drupal_ui/tests/src/Functional/SourceProviderTest.php
@@ -71,7 +71,7 @@ public static function providerSourceProvider() {
   /**
    * {@inheritdoc}
    */
-  protected function getSourceBasePath() {
+  protected function getSourceBasePath(): string {
     return '';
   }
 
diff --git a/core/modules/migrate_drupal_ui/tests/src/Functional/d6/IdConflictTest.php b/core/modules/migrate_drupal_ui/tests/src/Functional/d6/IdConflictTest.php
index 22555cfa42be..40deaccd0dcc 100644
--- a/core/modules/migrate_drupal_ui/tests/src/Functional/d6/IdConflictTest.php
+++ b/core/modules/migrate_drupal_ui/tests/src/Functional/d6/IdConflictTest.php
@@ -35,7 +35,7 @@ protected function setUp(): void {
   /**
    * {@inheritdoc}
    */
-  protected function getSourceBasePath() {
+  protected function getSourceBasePath(): string {
     return __DIR__ . '/files';
   }
 
diff --git a/core/modules/migrate_drupal_ui/tests/src/Functional/d6/MultilingualReviewPageTest.php b/core/modules/migrate_drupal_ui/tests/src/Functional/d6/MultilingualReviewPageTest.php
index 2042762b1e04..d73c524f96fa 100644
--- a/core/modules/migrate_drupal_ui/tests/src/Functional/d6/MultilingualReviewPageTest.php
+++ b/core/modules/migrate_drupal_ui/tests/src/Functional/d6/MultilingualReviewPageTest.php
@@ -47,7 +47,7 @@ protected function setUp(): void {
   /**
    * {@inheritdoc}
    */
-  protected function getSourceBasePath() {
+  protected function getSourceBasePath(): string {
     return __DIR__ . '/files';
   }
 
diff --git a/core/modules/migrate_drupal_ui/tests/src/Functional/d6/NoMultilingualReviewPageTest.php b/core/modules/migrate_drupal_ui/tests/src/Functional/d6/NoMultilingualReviewPageTest.php
index f06a359977e9..f0472434211c 100644
--- a/core/modules/migrate_drupal_ui/tests/src/Functional/d6/NoMultilingualReviewPageTest.php
+++ b/core/modules/migrate_drupal_ui/tests/src/Functional/d6/NoMultilingualReviewPageTest.php
@@ -43,7 +43,7 @@ protected function setUp(): void {
   /**
    * {@inheritdoc}
    */
-  protected function getSourceBasePath() {
+  protected function getSourceBasePath(): string {
     return __DIR__ . '/files';
   }
 
diff --git a/core/modules/migrate_drupal_ui/tests/src/Functional/d6/NodeClassicTest.php b/core/modules/migrate_drupal_ui/tests/src/Functional/d6/NodeClassicTest.php
index d8a3c455abb4..61a22b3b0cfe 100644
--- a/core/modules/migrate_drupal_ui/tests/src/Functional/d6/NodeClassicTest.php
+++ b/core/modules/migrate_drupal_ui/tests/src/Functional/d6/NodeClassicTest.php
@@ -42,7 +42,7 @@ protected function setUp(): void {
   /**
    * {@inheritdoc}
    */
-  protected function getSourceBasePath() {
+  protected function getSourceBasePath(): string {
     return __DIR__ . '/files';
   }
 
diff --git a/core/modules/migrate_drupal_ui/tests/src/Functional/d6/Upgrade6Test.php b/core/modules/migrate_drupal_ui/tests/src/Functional/d6/Upgrade6Test.php
index 9cd0cab57fc8..64dc7a1ea865 100644
--- a/core/modules/migrate_drupal_ui/tests/src/Functional/d6/Upgrade6Test.php
+++ b/core/modules/migrate_drupal_ui/tests/src/Functional/d6/Upgrade6Test.php
@@ -64,7 +64,7 @@ protected function setUp(): void {
   /**
    * {@inheritdoc}
    */
-  protected function getSourceBasePath() {
+  protected function getSourceBasePath(): string {
     return __DIR__ . '/files';
   }
 
diff --git a/core/modules/migrate_drupal_ui/tests/src/Functional/d7/DoubleSlashTest.php b/core/modules/migrate_drupal_ui/tests/src/Functional/d7/DoubleSlashTest.php
index d59c1af7c7e7..a8e8313a83b5 100644
--- a/core/modules/migrate_drupal_ui/tests/src/Functional/d7/DoubleSlashTest.php
+++ b/core/modules/migrate_drupal_ui/tests/src/Functional/d7/DoubleSlashTest.php
@@ -82,7 +82,7 @@ public function testMigrateUpgradeExecute(): void {
   /**
    * {@inheritdoc}
    */
-  protected function getSourceBasePath() {
+  protected function getSourceBasePath(): string {
     return __DIR__ . '/files';
   }
 
diff --git a/core/modules/migrate_drupal_ui/tests/src/Functional/d7/FilePathTest.php b/core/modules/migrate_drupal_ui/tests/src/Functional/d7/FilePathTest.php
index e2d3128c5a35..0ddc3c46d91e 100644
--- a/core/modules/migrate_drupal_ui/tests/src/Functional/d7/FilePathTest.php
+++ b/core/modules/migrate_drupal_ui/tests/src/Functional/d7/FilePathTest.php
@@ -317,7 +317,7 @@ protected function getMissingPaths(): array {
   /**
    * {@inheritdoc}
    */
-  protected function getSourceBasePath() {
+  protected function getSourceBasePath(): string {
     return '';
   }
 
diff --git a/core/modules/migrate_drupal_ui/tests/src/Functional/d7/IdConflictTest.php b/core/modules/migrate_drupal_ui/tests/src/Functional/d7/IdConflictTest.php
index cc3947c53100..e7f2c6971d04 100644
--- a/core/modules/migrate_drupal_ui/tests/src/Functional/d7/IdConflictTest.php
+++ b/core/modules/migrate_drupal_ui/tests/src/Functional/d7/IdConflictTest.php
@@ -35,7 +35,7 @@ protected function setUp(): void {
   /**
    * {@inheritdoc}
    */
-  protected function getSourceBasePath() {
+  protected function getSourceBasePath(): string {
     return __DIR__ . '/files';
   }
 
diff --git a/core/modules/migrate_drupal_ui/tests/src/Functional/d7/MultilingualReviewPageTest.php b/core/modules/migrate_drupal_ui/tests/src/Functional/d7/MultilingualReviewPageTest.php
index 8aeeba939c8f..83187a400c44 100644
--- a/core/modules/migrate_drupal_ui/tests/src/Functional/d7/MultilingualReviewPageTest.php
+++ b/core/modules/migrate_drupal_ui/tests/src/Functional/d7/MultilingualReviewPageTest.php
@@ -44,7 +44,7 @@ protected function setUp(): void {
   /**
    * {@inheritdoc}
    */
-  protected function getSourceBasePath() {
+  protected function getSourceBasePath(): string {
     return __DIR__ . '/files';
   }
 
diff --git a/core/modules/migrate_drupal_ui/tests/src/Functional/d7/NoMultilingualReviewPageTest.php b/core/modules/migrate_drupal_ui/tests/src/Functional/d7/NoMultilingualReviewPageTest.php
index c90f8227eaa8..42bea2226292 100644
--- a/core/modules/migrate_drupal_ui/tests/src/Functional/d7/NoMultilingualReviewPageTest.php
+++ b/core/modules/migrate_drupal_ui/tests/src/Functional/d7/NoMultilingualReviewPageTest.php
@@ -41,7 +41,7 @@ protected function setUp(): void {
   /**
    * {@inheritdoc}
    */
-  protected function getSourceBasePath() {
+  protected function getSourceBasePath(): string {
     return __DIR__ . '/files';
   }
 
diff --git a/core/modules/migrate_drupal_ui/tests/src/Functional/d7/Upgrade7Test.php b/core/modules/migrate_drupal_ui/tests/src/Functional/d7/Upgrade7Test.php
index 275b342178f6..46b3447e159d 100644
--- a/core/modules/migrate_drupal_ui/tests/src/Functional/d7/Upgrade7Test.php
+++ b/core/modules/migrate_drupal_ui/tests/src/Functional/d7/Upgrade7Test.php
@@ -67,7 +67,7 @@ protected function setUp(): void {
   /**
    * {@inheritdoc}
    */
-  protected function getSourceBasePath() {
+  protected function getSourceBasePath(): string {
     return __DIR__ . '/files';
   }
 
diff --git a/core/modules/node/tests/src/Functional/NodeTranslationUITest.php b/core/modules/node/tests/src/Functional/NodeTranslationUITest.php
index 47b359da747b..b3e02667a774 100644
--- a/core/modules/node/tests/src/Functional/NodeTranslationUITest.php
+++ b/core/modules/node/tests/src/Functional/NodeTranslationUITest.php
@@ -457,7 +457,7 @@ protected function doTestAlternateHreflangLinks(Node $node) {
   /**
    * {@inheritdoc}
    */
-  protected function getFormSubmitSuffix(EntityInterface $entity, $langcode) {
+  protected function getFormSubmitSuffix(EntityInterface $entity, $langcode): string {
     if (!$entity->isNew() && $entity->isTranslatable()) {
       $translations = $entity->getTranslationLanguages();
       if ((count($translations) > 1 || !isset($translations[$langcode])) && ($field = $entity->getFieldDefinition('status'))) {
diff --git a/core/modules/path/tests/src/Unit/Field/PathFieldDefinitionTest.php b/core/modules/path/tests/src/Unit/Field/PathFieldDefinitionTest.php
index 6e14d600d943..782ff2c3b02e 100644
--- a/core/modules/path/tests/src/Unit/Field/PathFieldDefinitionTest.php
+++ b/core/modules/path/tests/src/Unit/Field/PathFieldDefinitionTest.php
@@ -15,7 +15,7 @@ class PathFieldDefinitionTest extends BaseFieldDefinitionTestBase {
   /**
    * {@inheritdoc}
    */
-  protected function getPluginId() {
+  protected function getPluginId(): string {
     return 'path';
   }
 
diff --git a/core/modules/settings_tray/tests/src/Functional/SettingsTrayTest.php b/core/modules/settings_tray/tests/src/Functional/SettingsTrayTest.php
index d759696e9ea7..c9cc4ffa41e8 100644
--- a/core/modules/settings_tray/tests/src/Functional/SettingsTrayTest.php
+++ b/core/modules/settings_tray/tests/src/Functional/SettingsTrayTest.php
@@ -36,7 +36,7 @@ class SettingsTrayTest extends BrowserTestBase {
    * @return string
    *   The CSS selector.
    */
-  protected function getBlockSelector(Block $block) {
+  protected function getBlockSelector(Block $block): string {
     return '#block-' . $block->id();
   }
 
diff --git a/core/modules/system/tests/src/Functional/Form/FormStoragePageCacheTest.php b/core/modules/system/tests/src/Functional/Form/FormStoragePageCacheTest.php
index c3d617976ef6..47599fb0bc02 100644
--- a/core/modules/system/tests/src/Functional/Form/FormStoragePageCacheTest.php
+++ b/core/modules/system/tests/src/Functional/Form/FormStoragePageCacheTest.php
@@ -37,7 +37,7 @@ protected function setUp(): void {
   /**
    * Return the build id of the current form.
    */
-  protected function getFormBuildId() {
+  protected function getFormBuildId(): string {
     // Ensure the hidden 'form_build_id' field is unique.
     $this->assertSession()->elementsCount('xpath', '//input[@name="form_build_id"]', 1);
     return (string) $this->assertSession()->hiddenFieldExists('form_build_id')->getAttribute('value');
diff --git a/core/modules/system/tests/src/Functional/Session/SessionHttpsTest.php b/core/modules/system/tests/src/Functional/Session/SessionHttpsTest.php
index 12dade7f2098..ceee8c4ce4d9 100644
--- a/core/modules/system/tests/src/Functional/Session/SessionHttpsTest.php
+++ b/core/modules/system/tests/src/Functional/Session/SessionHttpsTest.php
@@ -232,7 +232,7 @@ protected function loginHttps(AccountInterface $account) {
    * @return string
    *   The internal path from the location header on the response.
    */
-  protected function getPathFromLocationHeader(ResponseInterface $response, $https = FALSE) {
+  protected function getPathFromLocationHeader(ResponseInterface $response, $https = FALSE): string {
     if ($https) {
       $base_url = str_replace('http://', 'https://', $this->baseUrl);
     }
@@ -276,7 +276,7 @@ protected function assertSessionIds(string $sid, string $assertion_text): void {
    * @return string
    *   URL prepared for the https.php mock front controller.
    */
-  protected function httpsUrl($url) {
+  protected function httpsUrl($url): string {
     return 'core/modules/system/tests/https.php/' . $url;
   }
 
@@ -289,7 +289,7 @@ protected function httpsUrl($url) {
    * @return string
    *   URL prepared for the http.php mock front controller.
    */
-  protected function httpUrl($url) {
+  protected function httpUrl($url): string {
     return 'core/modules/system/tests/http.php/' . $url;
   }
 
@@ -314,7 +314,7 @@ protected function getGuzzleCookieJar() {
    * @return string
    *   The form build ID for the user login form.
    */
-  protected function getUserLoginFormBuildId() {
+  protected function getUserLoginFormBuildId(): string {
     $this->drupalGet('user/login');
     return (string) $this->getSession()->getPage()->findField('form_build_id');
   }
diff --git a/core/modules/system/tests/src/Functional/System/SitesDirectoryHardeningTest.php b/core/modules/system/tests/src/Functional/System/SitesDirectoryHardeningTest.php
index 09bb7143667b..df7fd6d5c7be 100644
--- a/core/modules/system/tests/src/Functional/System/SitesDirectoryHardeningTest.php
+++ b/core/modules/system/tests/src/Functional/System/SitesDirectoryHardeningTest.php
@@ -115,7 +115,7 @@ protected function makeWritable($site_path) {
    * @return string
    *   The path to settings.php.
    */
-  protected function settingsFile($site_path) {
+  protected function settingsFile($site_path): string {
     $settings_file = $site_path . '/settings.php';
     return $settings_file;
   }
diff --git a/core/modules/user/tests/src/Functional/UserRegistrationRestTest.php b/core/modules/user/tests/src/Functional/UserRegistrationRestTest.php
index 49e46b8031b9..cb93659a4f40 100644
--- a/core/modules/user/tests/src/Functional/UserRegistrationRestTest.php
+++ b/core/modules/user/tests/src/Functional/UserRegistrationRestTest.php
@@ -258,7 +258,7 @@ protected function assertNormalizationEdgeCases($method, Url $url, array $reques
   /**
    * {@inheritdoc}
    */
-  protected function getExpectedUnauthorizedAccessMessage($method) {
+  protected function getExpectedUnauthorizedAccessMessage($method): string {
     return '';
   }
 
diff --git a/core/modules/views/tests/src/Kernel/Plugin/StyleMappingTest.php b/core/modules/views/tests/src/Kernel/Plugin/StyleMappingTest.php
index ec3842528bc5..008dfad6aada 100644
--- a/core/modules/views/tests/src/Kernel/Plugin/StyleMappingTest.php
+++ b/core/modules/views/tests/src/Kernel/Plugin/StyleMappingTest.php
@@ -47,7 +47,7 @@ public function testMappedOutput(): void {
    * @return string
    *   The view rendered as HTML.
    */
-  protected function mappedOutputHelper(ViewExecutable $view) {
+  protected function mappedOutputHelper(ViewExecutable $view): string {
     $output = $view->preview();
     $rendered_output = (string) \Drupal::service('renderer')->renderRoot($output);
     $this->storeViewPreview($rendered_output);
diff --git a/core/profiles/demo_umami/tests/src/Functional/UmamiMultilingualInstallTest.php b/core/profiles/demo_umami/tests/src/Functional/UmamiMultilingualInstallTest.php
index 30ef88da32a9..1cc06dfe03a7 100644
--- a/core/profiles/demo_umami/tests/src/Functional/UmamiMultilingualInstallTest.php
+++ b/core/profiles/demo_umami/tests/src/Functional/UmamiMultilingualInstallTest.php
@@ -53,7 +53,7 @@ protected function setUpLanguage() {
    * @return string
    *   Contents for the test .po file.
    */
-  protected function getPo($langcode) {
+  protected function getPo($langcode): string {
     return <<<PO
 msgid ""
 msgstr ""
diff --git a/core/tests/Drupal/FunctionalJavascriptTests/JSWebAssert.php b/core/tests/Drupal/FunctionalJavascriptTests/JSWebAssert.php
index fa49e03706e0..2dc675f8bb10 100644
--- a/core/tests/Drupal/FunctionalJavascriptTests/JSWebAssert.php
+++ b/core/tests/Drupal/FunctionalJavascriptTests/JSWebAssert.php
@@ -536,7 +536,7 @@ public function assertEscaped($raw) {
    *
    * @see Drupal\Component\Utility\Html::escape()
    */
-  protected function escapeHtml($raw) {
+  protected function escapeHtml($raw): string {
     return htmlspecialchars($raw, ENT_NOQUOTES | ENT_SUBSTITUTE, 'UTF-8');
   }
 
diff --git a/core/tests/Drupal/FunctionalJavascriptTests/PerformanceTestBase.php b/core/tests/Drupal/FunctionalJavascriptTests/PerformanceTestBase.php
index c3a4e6308738..e08e1c27b1d2 100644
--- a/core/tests/Drupal/FunctionalJavascriptTests/PerformanceTestBase.php
+++ b/core/tests/Drupal/FunctionalJavascriptTests/PerformanceTestBase.php
@@ -52,7 +52,7 @@ protected function installModulesFromClassProperty(ContainerInterface $container
   /**
    * {@inheritdoc}
    */
-  protected function getMinkDriverArgs() {
+  protected function getMinkDriverArgs(): string {
     return $this->doGetMinkDriverArgs();
   }
 
diff --git a/core/tests/Drupal/FunctionalTests/Installer/DistributionProfileTranslationQueryTest.php b/core/tests/Drupal/FunctionalTests/Installer/DistributionProfileTranslationQueryTest.php
index b895f7caa4b4..0e58711f4e38 100644
--- a/core/tests/Drupal/FunctionalTests/Installer/DistributionProfileTranslationQueryTest.php
+++ b/core/tests/Drupal/FunctionalTests/Installer/DistributionProfileTranslationQueryTest.php
@@ -133,7 +133,7 @@ public function testInstalled(): void {
    * @return string
    *   Contents for the test .po file.
    */
-  protected function getPo($langcode) {
+  protected function getPo($langcode): string {
     return <<<PO
 msgid ""
 msgstr ""
diff --git a/core/tests/Drupal/FunctionalTests/Installer/DistributionProfileTranslationTest.php b/core/tests/Drupal/FunctionalTests/Installer/DistributionProfileTranslationTest.php
index 0dd028e5ad05..3bb2b27995df 100644
--- a/core/tests/Drupal/FunctionalTests/Installer/DistributionProfileTranslationTest.php
+++ b/core/tests/Drupal/FunctionalTests/Installer/DistributionProfileTranslationTest.php
@@ -123,7 +123,7 @@ public function testInstalled(): void {
    * @return string
    *   Contents for the test .po file.
    */
-  protected function getPo($langcode) {
+  protected function getPo($langcode): string {
     return <<<PO
 msgid ""
 msgstr ""
diff --git a/core/tests/Drupal/FunctionalTests/Installer/InstallerExistingConfigMultilingualTest.php b/core/tests/Drupal/FunctionalTests/Installer/InstallerExistingConfigMultilingualTest.php
index 213003301bf1..8125da5bca05 100644
--- a/core/tests/Drupal/FunctionalTests/Installer/InstallerExistingConfigMultilingualTest.php
+++ b/core/tests/Drupal/FunctionalTests/Installer/InstallerExistingConfigMultilingualTest.php
@@ -21,7 +21,7 @@ class InstallerExistingConfigMultilingualTest extends InstallerConfigDirectoryTe
   /**
    * {@inheritdoc}
    */
-  protected function getConfigLocation() {
+  protected function getConfigLocation(): string {
     return __DIR__ . '/../../../fixtures/config_install/multilingual';
   }
 
diff --git a/core/tests/Drupal/FunctionalTests/Installer/InstallerExistingConfigNoConfigTest.php b/core/tests/Drupal/FunctionalTests/Installer/InstallerExistingConfigNoConfigTest.php
index 3f3f1aa36adb..2d5ac5c1c37d 100644
--- a/core/tests/Drupal/FunctionalTests/Installer/InstallerExistingConfigNoConfigTest.php
+++ b/core/tests/Drupal/FunctionalTests/Installer/InstallerExistingConfigNoConfigTest.php
@@ -28,7 +28,7 @@ protected function setUpSite() {
   /**
    * {@inheritdoc}
    */
-  protected function getConfigLocation() {
+  protected function getConfigLocation(): string {
     return __DIR__ . '/../../../fixtures/config_install/testing_config_install_no_config';
   }
 
diff --git a/core/tests/Drupal/FunctionalTests/Installer/InstallerExistingConfigNoSystemSiteTest.php b/core/tests/Drupal/FunctionalTests/Installer/InstallerExistingConfigNoSystemSiteTest.php
index 0631be6381f0..4af5caa3d17f 100644
--- a/core/tests/Drupal/FunctionalTests/Installer/InstallerExistingConfigNoSystemSiteTest.php
+++ b/core/tests/Drupal/FunctionalTests/Installer/InstallerExistingConfigNoSystemSiteTest.php
@@ -44,7 +44,7 @@ public function testConfigSync(): void {
   /**
    * {@inheritdoc}
    */
-  protected function getConfigLocation() {
+  protected function getConfigLocation(): string {
     return __DIR__ . '/../../../fixtures/config_install/testing_config_install';
   }
 
diff --git a/core/tests/Drupal/FunctionalTests/Installer/InstallerExistingConfigProfileHookInstall.php b/core/tests/Drupal/FunctionalTests/Installer/InstallerExistingConfigProfileHookInstall.php
index 13232d628a19..98f6ed3f3ed4 100644
--- a/core/tests/Drupal/FunctionalTests/Installer/InstallerExistingConfigProfileHookInstall.php
+++ b/core/tests/Drupal/FunctionalTests/Installer/InstallerExistingConfigProfileHookInstall.php
@@ -55,7 +55,7 @@ protected function setUpSite() {
   /**
    * {@inheritdoc}
    */
-  protected function getConfigLocation() {
+  protected function getConfigLocation(): string {
     // We're not going to get to the config import stage so this does not
     // matter.
     return __DIR__ . '/../../../fixtures/config_install/testing_config_install_no_config';
diff --git a/core/tests/Drupal/FunctionalTests/Installer/InstallerExistingConfigSyncDirectoryMultilingualTest.php b/core/tests/Drupal/FunctionalTests/Installer/InstallerExistingConfigSyncDirectoryMultilingualTest.php
index 73ca469a7e1c..d1a9bba36c35 100644
--- a/core/tests/Drupal/FunctionalTests/Installer/InstallerExistingConfigSyncDirectoryMultilingualTest.php
+++ b/core/tests/Drupal/FunctionalTests/Installer/InstallerExistingConfigSyncDirectoryMultilingualTest.php
@@ -43,7 +43,7 @@ protected function setUpProfile() {
   /**
    * {@inheritdoc}
    */
-  protected function getConfigLocation() {
+  protected function getConfigLocation(): string {
     return __DIR__ . '/../../../fixtures/config_install/multilingual';
   }
 
@@ -195,7 +195,7 @@ public function testConfigSync(): void {
    * @return string
    *   Contents for the test .po file.
    */
-  protected function getPo($langcode) {
+  protected function getPo($langcode): string {
     return <<<PO
 msgid ""
 msgstr ""
diff --git a/core/tests/Drupal/FunctionalTests/Installer/InstallerExistingConfigSyncDirectoryProfileHookInstall.php b/core/tests/Drupal/FunctionalTests/Installer/InstallerExistingConfigSyncDirectoryProfileHookInstall.php
index a0601e350599..dc68050ae5dd 100644
--- a/core/tests/Drupal/FunctionalTests/Installer/InstallerExistingConfigSyncDirectoryProfileHookInstall.php
+++ b/core/tests/Drupal/FunctionalTests/Installer/InstallerExistingConfigSyncDirectoryProfileHookInstall.php
@@ -74,7 +74,7 @@ protected function setUpSite() {
   /**
    * {@inheritdoc}
    */
-  protected function getConfigLocation() {
+  protected function getConfigLocation(): string {
     return __DIR__ . '/../../../fixtures/config_install/multilingual';
   }
 
diff --git a/core/tests/Drupal/FunctionalTests/Installer/InstallerExistingConfigSyncDirectoryProfileMismatchTest.php b/core/tests/Drupal/FunctionalTests/Installer/InstallerExistingConfigSyncDirectoryProfileMismatchTest.php
index bd194ee0f134..e63254cd338a 100644
--- a/core/tests/Drupal/FunctionalTests/Installer/InstallerExistingConfigSyncDirectoryProfileMismatchTest.php
+++ b/core/tests/Drupal/FunctionalTests/Installer/InstallerExistingConfigSyncDirectoryProfileMismatchTest.php
@@ -29,7 +29,7 @@ class InstallerExistingConfigSyncDirectoryProfileMismatchTest extends InstallerC
   /**
    * {@inheritdoc}
    */
-  protected function getConfigLocation() {
+  protected function getConfigLocation(): string {
     return __DIR__ . '/../../../fixtures/config_install/multilingual';
   }
 
diff --git a/core/tests/Drupal/FunctionalTests/Installer/InstallerExistingConfigTest.php b/core/tests/Drupal/FunctionalTests/Installer/InstallerExistingConfigTest.php
index 166974eab4e9..ac3860b4f8f6 100644
--- a/core/tests/Drupal/FunctionalTests/Installer/InstallerExistingConfigTest.php
+++ b/core/tests/Drupal/FunctionalTests/Installer/InstallerExistingConfigTest.php
@@ -37,7 +37,7 @@ public function setUpSettings() {
   /**
    * {@inheritdoc}
    */
-  protected function getConfigLocation() {
+  protected function getConfigLocation(): string {
     return __DIR__ . '/../../../fixtures/config_install/testing_config_install';
   }
 
diff --git a/core/tests/Drupal/FunctionalTests/Installer/InstallerTranslationMultipleLanguageNonInteractiveTest.php b/core/tests/Drupal/FunctionalTests/Installer/InstallerTranslationMultipleLanguageNonInteractiveTest.php
index 6c4ad5c6d83a..9463ef7090ca 100644
--- a/core/tests/Drupal/FunctionalTests/Installer/InstallerTranslationMultipleLanguageNonInteractiveTest.php
+++ b/core/tests/Drupal/FunctionalTests/Installer/InstallerTranslationMultipleLanguageNonInteractiveTest.php
@@ -47,7 +47,7 @@ protected function prepareEnvironment() {
    * @return string
    *   Contents for the test .po file.
    */
-  protected function getPo($langcode) {
+  protected function getPo($langcode): string {
     return <<<PO
 msgid ""
 msgstr ""
diff --git a/core/tests/Drupal/FunctionalTests/Installer/InstallerTranslationMultipleLanguageTest.php b/core/tests/Drupal/FunctionalTests/Installer/InstallerTranslationMultipleLanguageTest.php
index bb2f5fb381c0..0f9f0676cef9 100644
--- a/core/tests/Drupal/FunctionalTests/Installer/InstallerTranslationMultipleLanguageTest.php
+++ b/core/tests/Drupal/FunctionalTests/Installer/InstallerTranslationMultipleLanguageTest.php
@@ -44,7 +44,7 @@ protected function setUpLanguage() {
    * @return string
    *   Contents for the test .po file.
    */
-  protected function getPo($langcode) {
+  protected function getPo($langcode): string {
     return <<<PO
 msgid ""
 msgstr ""
diff --git a/core/tests/Drupal/FunctionalTests/Installer/InstallerTranslationQueryTest.php b/core/tests/Drupal/FunctionalTests/Installer/InstallerTranslationQueryTest.php
index f085ae3d034c..03b42c2ffd31 100644
--- a/core/tests/Drupal/FunctionalTests/Installer/InstallerTranslationQueryTest.php
+++ b/core/tests/Drupal/FunctionalTests/Installer/InstallerTranslationQueryTest.php
@@ -76,7 +76,7 @@ public function testInstaller(): void {
    * @return string
    *   Contents for the test .po file.
    */
-  protected function getPo($langcode) {
+  protected function getPo($langcode): string {
     return <<<PO
 msgid ""
 msgstr ""
diff --git a/core/tests/Drupal/FunctionalTests/Installer/InstallerTranslationTest.php b/core/tests/Drupal/FunctionalTests/Installer/InstallerTranslationTest.php
index fa9368b2e9d4..7cc32bd6e081 100644
--- a/core/tests/Drupal/FunctionalTests/Installer/InstallerTranslationTest.php
+++ b/core/tests/Drupal/FunctionalTests/Installer/InstallerTranslationTest.php
@@ -154,7 +154,7 @@ public function testInstaller(): void {
    * @return string
    *   Contents for the test .po file.
    */
-  protected function getPo($langcode) {
+  protected function getPo($langcode): string {
     return <<<PO
 msgid ""
 msgstr ""
diff --git a/core/tests/Drupal/KernelTests/Core/Entity/EntityDecoupledTranslationRevisionsTest.php b/core/tests/Drupal/KernelTests/Core/Entity/EntityDecoupledTranslationRevisionsTest.php
index 81338be40ebc..4717b9801e63 100644
--- a/core/tests/Drupal/KernelTests/Core/Entity/EntityDecoupledTranslationRevisionsTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Entity/EntityDecoupledTranslationRevisionsTest.php
@@ -469,7 +469,7 @@ protected function doEditStep($active_langcode, $default_revision, $untranslatab
    * @return string
    *   A revision label.
    */
-  protected function generateNewEntityLabel(ContentEntityInterface $revision, $previous_revision_id, $next = FALSE) {
+  protected function generateNewEntityLabel(ContentEntityInterface $revision, $previous_revision_id, $next = FALSE): string {
     $language_label = $revision->language()->getName();
     $revision_type = $revision->isDefaultRevision() ? 'Default' : 'Pending';
     $revision_id = $next ? $this->storage->getLatestRevisionId($revision->id()) + 1 : $revision->getLoadedRevisionId();
diff --git a/core/tests/Drupal/Tests/BrowserHtmlDebugTrait.php b/core/tests/Drupal/Tests/BrowserHtmlDebugTrait.php
index ffb68f7d762c..95c568afd683 100644
--- a/core/tests/Drupal/Tests/BrowserHtmlDebugTrait.php
+++ b/core/tests/Drupal/Tests/BrowserHtmlDebugTrait.php
@@ -73,7 +73,7 @@ trait BrowserHtmlDebugTrait {
    * @return string
    *   The formatted HTML string.
    */
-  protected function formatHtmlOutputHeaders(array $headers) {
+  protected function formatHtmlOutputHeaders(array $headers): string {
     $flattened_headers = array_map(function ($header) {
       if (is_array($header)) {
         return implode(';', array_map('trim', $header));
diff --git a/core/tests/Drupal/Tests/Component/DependencyInjection/Dumper/PhpArrayDumperTest.php b/core/tests/Drupal/Tests/Component/DependencyInjection/Dumper/PhpArrayDumperTest.php
index 6474e9aa8119..0573f1b27a2a 100644
--- a/core/tests/Drupal/Tests/Component/DependencyInjection/Dumper/PhpArrayDumperTest.php
+++ b/core/tests/Drupal/Tests/Component/DependencyInjection/Dumper/PhpArrayDumperTest.php
@@ -31,7 +31,7 @@ protected static function serializeDefinition(array $service_definition): array
   /**
    * {@inheritdoc}
    */
-  protected static function getServiceCall($id, $invalid_behavior = ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE) {
+  protected static function getServiceCall($id, $invalid_behavior = ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE): string {
     if ($invalid_behavior !== ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE) {
       return sprintf('@?%s', $id);
     }
@@ -42,7 +42,7 @@ protected static function getServiceCall($id, $invalid_behavior = ContainerInter
   /**
    * {@inheritdoc}
    */
-  protected static function getParameterCall($name) {
+  protected static function getParameterCall($name): string {
     return '%' . $name . '%';
   }
 
diff --git a/core/tests/Drupal/Tests/Component/DependencyInjection/PhpArrayContainerTest.php b/core/tests/Drupal/Tests/Component/DependencyInjection/PhpArrayContainerTest.php
index 03cb68a3dc05..99113913a7f2 100644
--- a/core/tests/Drupal/Tests/Component/DependencyInjection/PhpArrayContainerTest.php
+++ b/core/tests/Drupal/Tests/Component/DependencyInjection/PhpArrayContainerTest.php
@@ -27,7 +27,7 @@ protected function setUp(): void {
   /**
    * Helper function to return a service definition.
    */
-  protected function getServiceCall($id, $invalid_behavior = ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE) {
+  protected function getServiceCall($id, $invalid_behavior = ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE): string {
     if ($invalid_behavior !== ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE) {
       return sprintf('@?%s', $id);
     }
@@ -38,7 +38,7 @@ protected function getServiceCall($id, $invalid_behavior = ContainerInterface::E
   /**
    * Helper function to return a service definition.
    */
-  protected function getParameterCall($name) {
+  protected function getParameterCall($name): string {
     return '%' . $name . '%';
   }
 
diff --git a/core/tests/Drupal/Tests/Component/Graph/GraphTest.php b/core/tests/Drupal/Tests/Component/Graph/GraphTest.php
index 2c50ca43f667..ab600c4a6f00 100644
--- a/core/tests/Drupal/Tests/Component/Graph/GraphTest.php
+++ b/core/tests/Drupal/Tests/Component/Graph/GraphTest.php
@@ -191,7 +191,7 @@ protected function assertWeights(array $graph, array $expected_orders): void {
    * @param $keys
    *   (optional) Whether to output the keys of $paths instead of the values.
    */
-  protected function displayArray($paths, $keys = FALSE) {
+  protected function displayArray($paths, $keys = FALSE): string {
     if (!empty($paths)) {
       return implode(', ', $keys ? array_keys($paths) : $paths);
     }
diff --git a/core/tests/Drupal/Tests/Composer/Plugin/Scaffold/ExecTrait.php b/core/tests/Drupal/Tests/Composer/Plugin/Scaffold/ExecTrait.php
index 976005a31ffc..142ebbf52f2b 100644
--- a/core/tests/Drupal/Tests/Composer/Plugin/Scaffold/ExecTrait.php
+++ b/core/tests/Drupal/Tests/Composer/Plugin/Scaffold/ExecTrait.php
@@ -24,7 +24,7 @@ trait ExecTrait {
    * @return string
    *   Standard output from the command
    */
-  protected function mustExec($cmd, $cwd, array $env = []) {
+  protected function mustExec($cmd, $cwd, array $env = []): string {
     $process = Process::fromShellCommandline($cmd, $cwd, $env + ['PATH' => getenv('PATH'), 'HOME' => getenv('HOME')]);
     $process->setTimeout(300)->setIdleTimeout(300)->run();
     $exitCode = $process->getExitCode();
diff --git a/core/tests/Drupal/Tests/Composer/Plugin/Scaffold/Functional/ManageGitIgnoreTest.php b/core/tests/Drupal/Tests/Composer/Plugin/Scaffold/Functional/ManageGitIgnoreTest.php
index 634b4018c592..c7fd1d4d7797 100644
--- a/core/tests/Drupal/Tests/Composer/Plugin/Scaffold/Functional/ManageGitIgnoreTest.php
+++ b/core/tests/Drupal/Tests/Composer/Plugin/Scaffold/Functional/ManageGitIgnoreTest.php
@@ -82,7 +82,7 @@ protected function tearDown(): void {
    * @return string
    *   The path to the fixture directory.
    */
-  protected function createSutWithGit($fixture_name) {
+  protected function createSutWithGit($fixture_name): string {
     $this->fixturesDir = $this->fixtures->tmpDir($this->name());
     $sut = $this->fixturesDir . '/' . $fixture_name;
     $replacements = ['SYMLINK' => 'false', 'PROJECT_ROOT' => $this->projectRoot];
diff --git a/core/tests/Drupal/Tests/Composer/Plugin/Scaffold/Functional/ScaffoldTest.php b/core/tests/Drupal/Tests/Composer/Plugin/Scaffold/Functional/ScaffoldTest.php
index 79077da9ce3c..81ee13a5bc5f 100644
--- a/core/tests/Drupal/Tests/Composer/Plugin/Scaffold/Functional/ScaffoldTest.php
+++ b/core/tests/Drupal/Tests/Composer/Plugin/Scaffold/Functional/ScaffoldTest.php
@@ -90,7 +90,7 @@ protected function tearDown(): void {
    * @return string
    *   The path to the created System-Under-Test.
    */
-  protected function createSut($fixture_name, array $replacements = []) {
+  protected function createSut($fixture_name, array $replacements = []): string {
     $sut = $this->fixturesDir . '/' . $fixture_name;
     // Erase just our sut, to ensure it is clean. Recopy all of the fixtures.
     $this->fileSystem->remove($sut);
diff --git a/core/tests/Drupal/Tests/Composer/Plugin/Scaffold/Functional/ScaffoldUpgradeTest.php b/core/tests/Drupal/Tests/Composer/Plugin/Scaffold/Functional/ScaffoldUpgradeTest.php
index f0c687bc439d..381872916b4f 100644
--- a/core/tests/Drupal/Tests/Composer/Plugin/Scaffold/Functional/ScaffoldUpgradeTest.php
+++ b/core/tests/Drupal/Tests/Composer/Plugin/Scaffold/Functional/ScaffoldUpgradeTest.php
@@ -114,7 +114,7 @@ public function testScaffoldUpgrade(): void {
    * @return string
    *   Path to temporary git repository.
    */
-  protected function createTmpRepo($source, $destParent, $version) {
+  protected function createTmpRepo($source, $destParent, $version): string {
     $target = $destParent . '/' . basename($source);
     $filesystem = new Filesystem();
     $filesystem->copy($source, $target);
diff --git a/core/tests/Drupal/Tests/ComposerIntegrationTest.php b/core/tests/Drupal/Tests/ComposerIntegrationTest.php
index f2dfe4bf73cd..10f9bb0774da 100644
--- a/core/tests/Drupal/Tests/ComposerIntegrationTest.php
+++ b/core/tests/Drupal/Tests/ComposerIntegrationTest.php
@@ -217,7 +217,7 @@ public function testExpectedScaffoldFiles($destRelPath, $sourceRelPath, $expecte
    *
    * @return string
    */
-  protected static function getContentHash($composerFileContents)
+  protected static function getContentHash($composerFileContents): string
   {
     $content = json_decode($composerFileContents, true);
 
diff --git a/core/tests/Drupal/Tests/Core/Cache/VariationCacheTest.php b/core/tests/Drupal/Tests/Core/Cache/VariationCacheTest.php
index 61b058b7e2f2..1c7a34ac43d5 100644
--- a/core/tests/Drupal/Tests/Core/Cache/VariationCacheTest.php
+++ b/core/tests/Drupal/Tests/Core/Cache/VariationCacheTest.php
@@ -434,7 +434,7 @@ public function testIncompatibleVariationsException(): void {
    * @return string
    *   The correct cache ID.
    */
-  protected function getSortedCacheId($cache_id_parts) {
+  protected function getSortedCacheId($cache_id_parts): string {
     sort($cache_id_parts);
     array_unshift($cache_id_parts, $this->cacheIdBase);
     return implode(':', $cache_id_parts);
diff --git a/core/tests/Drupal/Tests/Core/Entity/EntityTypeManagerTest.php b/core/tests/Drupal/Tests/Core/Entity/EntityTypeManagerTest.php
index a3e5953ea580..3cd018285c0e 100644
--- a/core/tests/Drupal/Tests/Core/Entity/EntityTypeManagerTest.php
+++ b/core/tests/Drupal/Tests/Core/Entity/EntityTypeManagerTest.php
@@ -452,7 +452,7 @@ public function testGetDefinitionInvalidException(): void {
    * @return string
    *   A mock controller class name.
    */
-  protected function getTestHandlerClass() {
+  protected function getTestHandlerClass(): string {
     return get_class($this->getMockForAbstractClass(EntityHandlerBase::class));
   }
 
diff --git a/core/tests/Drupal/Tests/Core/Entity/EntityTypeTest.php b/core/tests/Drupal/Tests/Core/Entity/EntityTypeTest.php
index c70a98aded4f..d334ed95176f 100644
--- a/core/tests/Drupal/Tests/Core/Entity/EntityTypeTest.php
+++ b/core/tests/Drupal/Tests/Core/Entity/EntityTypeTest.php
@@ -446,7 +446,7 @@ public static function providerTestGetBundleLabel() {
    * @return string
    *   A mock controller class name.
    */
-  protected function getTestHandlerClass() {
+  protected function getTestHandlerClass(): string {
     return get_class($this->getMockForAbstractClass('Drupal\Core\Entity\EntityHandlerBase'));
   }
 
diff --git a/core/tests/Drupal/Tests/Core/Plugin/FilteredPluginManagerTraitTest.php b/core/tests/Drupal/Tests/Core/Plugin/FilteredPluginManagerTraitTest.php
index 93a4e1942e87..b7c4e927dc3d 100644
--- a/core/tests/Drupal/Tests/Core/Plugin/FilteredPluginManagerTraitTest.php
+++ b/core/tests/Drupal/Tests/Core/Plugin/FilteredPluginManagerTraitTest.php
@@ -112,7 +112,7 @@ protected function themeManager() {
     return $this->themeManager;
   }
 
-  protected function getType() {
+  protected function getType(): string {
     return 'the_type';
   }
 
diff --git a/core/tests/Drupal/Tests/RandomGeneratorTrait.php b/core/tests/Drupal/Tests/RandomGeneratorTrait.php
index ac2b337cdf69..e2f964b1065e 100644
--- a/core/tests/Drupal/Tests/RandomGeneratorTrait.php
+++ b/core/tests/Drupal/Tests/RandomGeneratorTrait.php
@@ -47,7 +47,7 @@ public function randomString($length = 8) {
    *
    * @see \Drupal\Component\Utility\Random::name()
    */
-  protected function randomMachineName($length = 8) {
+  protected function randomMachineName($length = 8): string {
     return Random::machineName($length);
   }
 
diff --git a/core/tests/Drupal/Tests/Scripts/TestSiteApplicationTest.php b/core/tests/Drupal/Tests/Scripts/TestSiteApplicationTest.php
index a5e71bfb4d8c..0c4b6f27d99c 100644
--- a/core/tests/Drupal/Tests/Scripts/TestSiteApplicationTest.php
+++ b/core/tests/Drupal/Tests/Scripts/TestSiteApplicationTest.php
@@ -299,7 +299,7 @@ public function testUserLogin(): void {
    * @return string
    *   The database key of the added connection.
    */
-  protected function addTestDatabase($db_prefix) {
+  protected function addTestDatabase($db_prefix): string {
     $database = Database::convertDbUrlToConnectionInfo(getenv('SIMPLETEST_DB'), $this->root);
     $database['prefix'] = $db_prefix;
     $target = __CLASS__ . $db_prefix;
@@ -316,7 +316,7 @@ protected function addTestDatabase($db_prefix) {
    * @return string
    *   The lock file path.
    */
-  protected function getTestLockFile($db_prefix) {
+  protected function getTestLockFile($db_prefix): string {
     $lock_id = str_replace('test', '', $db_prefix);
     return FileSystem::getOsTemporaryDirectory() . '/test_' . $lock_id;
   }
diff --git a/core/tests/Drupal/Tests/TestRequirementsTrait.php b/core/tests/Drupal/Tests/TestRequirementsTrait.php
index ce445573981a..04c2eb411dba 100644
--- a/core/tests/Drupal/Tests/TestRequirementsTrait.php
+++ b/core/tests/Drupal/Tests/TestRequirementsTrait.php
@@ -18,7 +18,7 @@ trait TestRequirementsTrait {
    *
    * @return string
    */
-  protected static function getDrupalRoot() {
+  protected static function getDrupalRoot(): string {
     return dirname(substr(__DIR__, 0, -strlen(__NAMESPACE__)), 2);
   }
 
diff --git a/core/tests/Drupal/Tests/UiHelperTrait.php b/core/tests/Drupal/Tests/UiHelperTrait.php
index a1ea81aec367..cd606a6ccdbe 100644
--- a/core/tests/Drupal/Tests/UiHelperTrait.php
+++ b/core/tests/Drupal/Tests/UiHelperTrait.php
@@ -509,7 +509,7 @@ protected function cssSelect($selector) {
    * @return string
    *   The equivalent XPath of a CSS expression.
    */
-  protected function cssSelectToXpath($selector, $html = TRUE, $prefix = 'descendant-or-self::') {
+  protected function cssSelectToXpath($selector, $html = TRUE, $prefix = 'descendant-or-self::'): string {
     return (new CssSelectorConverter($html))->toXPath($selector, $prefix);
   }
 
-- 
GitLab