diff --git a/core/modules/jsonapi/tests/src/Functional/ResourceResponseTestTrait.php b/core/modules/jsonapi/tests/src/Functional/ResourceResponseTestTrait.php
index cff7df2cbd83743d5c8fa27ed9cc2357413b45ea..d1b90c025ec41687e95b89dad14b851bda1fd233 100644
--- a/core/modules/jsonapi/tests/src/Functional/ResourceResponseTestTrait.php
+++ b/core/modules/jsonapi/tests/src/Functional/ResourceResponseTestTrait.php
@@ -276,7 +276,7 @@ protected static function toResourceIdentifier(EntityInterface $entity): array {
    * @return bool
    *   TRUE if the array has a type and ID, FALSE otherwise.
    */
-  protected static function isResourceIdentifier(array $data) {
+  protected static function isResourceIdentifier(array $data): bool {
     return array_key_exists('type', $data) && array_key_exists('id', $data);
   }
 
diff --git a/core/modules/language/tests/src/Functional/LanguageNegotiationInfoTest.php b/core/modules/language/tests/src/Functional/LanguageNegotiationInfoTest.php
index e2640da9926feaaef5bae091ab5b710641e3185a..6839b74a02067914bfd110e1b65efa4578818c9f 100644
--- a/core/modules/language/tests/src/Functional/LanguageNegotiationInfoTest.php
+++ b/core/modules/language/tests/src/Functional/LanguageNegotiationInfoTest.php
@@ -215,7 +215,7 @@ public function testConfigLangTypeAlterations(): void {
    * @return bool
    *   TRUE if the specified language type is configurable, FALSE otherwise.
    */
-  protected function isLanguageTypeConfigurable($type) {
+  protected function isLanguageTypeConfigurable($type): bool {
     $configurable_types = $this->config('language.types')->get('configurable');
     return in_array($type, $configurable_types);
   }
diff --git a/core/modules/migrate/tests/src/Kernel/HighWaterTest.php b/core/modules/migrate/tests/src/Kernel/HighWaterTest.php
index 35fdf14d6d936c085c7589e80f52241810d6519c..28b4f633bfc730e829ad7f448fde0903e4021f8c 100644
--- a/core/modules/migrate/tests/src/Kernel/HighWaterTest.php
+++ b/core/modules/migrate/tests/src/Kernel/HighWaterTest.php
@@ -296,7 +296,7 @@ protected function assertNodeDoesNotExist(string $title): void {
    *
    * @return bool
    */
-  protected function nodeExists($title) {
+  protected function nodeExists($title): bool {
     $query = \Drupal::entityQuery('node')->accessCheck(FALSE);
     $result = $query
       ->condition('title', $title)
diff --git a/core/modules/migrate/tests/src/Kernel/TrackChangesTest.php b/core/modules/migrate/tests/src/Kernel/TrackChangesTest.php
index 0cd0d18f4d6b44115bc5b07454c29ce98e291c2d..03f8d74f20cc81cb948dc31ef63d698ac907a613 100644
--- a/core/modules/migrate/tests/src/Kernel/TrackChangesTest.php
+++ b/core/modules/migrate/tests/src/Kernel/TrackChangesTest.php
@@ -226,7 +226,7 @@ protected function assertTermDoesNotExist(string $property, string $value): void
    *
    * @return bool
    */
-  protected function termExists($property, $value) {
+  protected function termExists($property, $value): bool {
     $property = $property === 'description' ? 'description__value' : $property;
     $query = \Drupal::entityQuery('taxonomy_term')->accessCheck(FALSE);
     $result = $query
diff --git a/core/modules/system/tests/src/Functional/Cache/AssertPageCacheContextsAndTagsTrait.php b/core/modules/system/tests/src/Functional/Cache/AssertPageCacheContextsAndTagsTrait.php
index d2cb0f1966f4e13ec33d00f7f5f9f566c18b3f17..760c5a8a2eae718d2c6bcbe32490cde8db8d8612 100644
--- a/core/modules/system/tests/src/Functional/Cache/AssertPageCacheContextsAndTagsTrait.php
+++ b/core/modules/system/tests/src/Functional/Cache/AssertPageCacheContextsAndTagsTrait.php
@@ -129,7 +129,7 @@ protected function assertCacheTags(array $expected_tags, $include_default_tags =
    * @return bool
    *   Always returns TRUE.
    */
-  protected function assertCacheContexts(array $expected_contexts, $message = NULL, $include_default_contexts = TRUE) {
+  protected function assertCacheContexts(array $expected_contexts, $message = NULL, $include_default_contexts = TRUE): bool {
     if ($include_default_contexts) {
       $default_contexts = ['languages:language_interface', 'theme'];
       // Add the user based contexts to the list of default contexts except when
diff --git a/core/modules/system/tests/src/Kernel/Common/UrlTest.php b/core/modules/system/tests/src/Kernel/Common/UrlTest.php
index 43644fac54a17be9f9ea59b19e1ebeff99aca141..d087d73c51e2aaaff427eb3aa9caff7c5c4a3197 100644
--- a/core/modules/system/tests/src/Kernel/Common/UrlTest.php
+++ b/core/modules/system/tests/src/Kernel/Common/UrlTest.php
@@ -175,7 +175,7 @@ public function testLinkRenderArrayText(): void {
    * @return bool
    *   TRUE if the class is found, FALSE otherwise.
    */
-  private function hasAttribute($attribute, $link, $class) {
+  private function hasAttribute($attribute, $link, $class): bool {
     return (bool) preg_match('|' . $attribute . '="([^\"\s]+\s+)*' . $class . '|', $link);
   }
 
diff --git a/core/tests/Drupal/KernelTests/AssertContentTrait.php b/core/tests/Drupal/KernelTests/AssertContentTrait.php
index 5ac79b9100c444dec77887820fbb2757b0454634..03e560bc0e6a06b210fc16dec138a82d4a69e953 100644
--- a/core/tests/Drupal/KernelTests/AssertContentTrait.php
+++ b/core/tests/Drupal/KernelTests/AssertContentTrait.php
@@ -278,7 +278,7 @@ protected function getAllOptions(\SimpleXMLElement $element): array {
    * @return bool
    *   TRUE if the assertion succeeded.
    */
-  protected function assertLink($label, $index = 0, $message = '') {
+  protected function assertLink($label, $index = 0, $message = ''): bool {
     // Cast MarkupInterface objects to string.
     $label = (string) $label;
     $links = $this->xpath('//a[normalize-space(text())=:label]', [':label' => $label]);
@@ -301,7 +301,7 @@ protected function assertLink($label, $index = 0, $message = '') {
    * @return bool
    *   TRUE if the assertion succeeded.
    */
-  protected function assertNoLink($label, $message = '') {
+  protected function assertNoLink($label, $message = ''): bool {
     // Cast MarkupInterface objects to string.
     $label = (string) $label;
     $links = $this->xpath('//a[normalize-space(text())=:label]', [':label' => $label]);
@@ -326,7 +326,7 @@ protected function assertNoLink($label, $message = '') {
    * @return bool
    *   TRUE if the assertion succeeded.
    */
-  protected function assertLinkByHref($href, $index = 0, $message = '') {
+  protected function assertLinkByHref($href, $index = 0, $message = ''): bool {
     $links = $this->xpath('//a[contains(@href, :href)]', [':href' => $href]);
     $message = ($message ? $message : new FormattableMarkup('Link containing href %href found.', ['%href' => $href]));
     $this->assertArrayHasKey($index, $links, $message);
@@ -347,7 +347,7 @@ protected function assertLinkByHref($href, $index = 0, $message = '') {
    * @return bool
    *   TRUE if the assertion succeeded.
    */
-  protected function assertNoLinkByHref($href, $message = '') {
+  protected function assertNoLinkByHref($href, $message = ''): bool {
     $links = $this->xpath('//a[contains(@href, :href)]', [':href' => $href]);
     $message = ($message ? $message : new FormattableMarkup('No link containing href %href found.', ['%href' => $href]));
     $this->assertEmpty($links, $message);
@@ -368,7 +368,7 @@ protected function assertNoLinkByHref($href, $message = '') {
    * @return bool
    *   TRUE if the assertion succeeded.
    */
-  protected function assertNoLinkByHrefInMainRegion($href, $message = '') {
+  protected function assertNoLinkByHrefInMainRegion($href, $message = ''): bool {
     $links = $this->xpath('//main//a[contains(@href, :href)]', [':href' => $href]);
     $message = ($message ? $message : new FormattableMarkup('No link containing href %href found.', ['%href' => $href]));
     $this->assertEmpty($links, $message);
@@ -590,7 +590,7 @@ protected function assertNoUniqueText($text, $message = '') {
    * @return bool
    *   TRUE on pass.
    */
-  protected function assertUniqueTextHelper($text, $message = '', $group = NULL, $be_unique = FALSE) {
+  protected function assertUniqueTextHelper($text, $message = '', $group = NULL, $be_unique = FALSE): bool {
     // Cast MarkupInterface objects to string.
     $text = (string) $text;
     if (!$message) {
@@ -620,7 +620,7 @@ protected function assertUniqueTextHelper($text, $message = '', $group = NULL, $
    * @return bool
    *   TRUE on pass.
    */
-  protected function assertPattern($pattern, $message = '') {
+  protected function assertPattern($pattern, $message = ''): bool {
     if (!$message) {
       $message = new FormattableMarkup('Pattern "@pattern" found', ['@pattern' => $pattern]);
     }
@@ -642,7 +642,7 @@ protected function assertPattern($pattern, $message = '') {
    * @return bool
    *   TRUE on pass.
    */
-  protected function assertNoPattern($pattern, $message = '') {
+  protected function assertNoPattern($pattern, $message = ''): bool {
     if (!$message) {
       $message = new FormattableMarkup('Pattern "@pattern" not found', ['@pattern' => $pattern]);
     }
@@ -661,7 +661,7 @@ protected function assertNoPattern($pattern, $message = '') {
    * @return bool
    *   TRUE on pass.
    */
-  protected function assertTextPattern($pattern, $message = NULL) {
+  protected function assertTextPattern($pattern, $message = NULL): bool {
     if (!isset($message)) {
       $message = new FormattableMarkup('Pattern "@pattern" found', ['@pattern' => $pattern]);
     }
@@ -769,7 +769,7 @@ protected function assertThemeOutput($callback, array $variables = [], $expected
    * @return bool
    *   TRUE on pass.
    */
-  protected function assertFieldsByValue($fields, $value = NULL, $message = '') {
+  protected function assertFieldsByValue($fields, $value = NULL, $message = ''): bool {
     // If value specified then check array for match.
     $found = TRUE;
     if (isset($value)) {
@@ -870,7 +870,7 @@ protected function getSelectedItem(\SimpleXMLElement $element) {
    * @return bool
    *   TRUE on pass.
    */
-  protected function assertNoFieldByXPath($xpath, $value = NULL, $message = '') {
+  protected function assertNoFieldByXPath($xpath, $value = NULL, $message = ''): bool {
     $fields = $this->xpath($xpath);
 
     // If value specified then check array for match.
@@ -1013,7 +1013,7 @@ protected function assertNoFieldById($id, $value = '', $message = '') {
    * @return bool
    *   TRUE on pass.
    */
-  protected function assertFieldChecked($id, $message = '') {
+  protected function assertFieldChecked($id, $message = ''): bool {
     $message = $message ? $message : new FormattableMarkup('Checkbox field @id is checked.', ['@id' => $id]);
     $elements = $this->xpath('//input[@id=:id]', [':id' => $id]);
     $this->assertNotEmpty($elements, $message);
@@ -1035,7 +1035,7 @@ protected function assertFieldChecked($id, $message = '') {
    * @return bool
    *   TRUE on pass.
    */
-  protected function assertNoFieldChecked($id, $message = '') {
+  protected function assertNoFieldChecked($id, $message = ''): bool {
     $message = $message ? $message : new FormattableMarkup('Checkbox field @id is not checked.', ['@id' => $id]);
     $elements = $this->xpath('//input[@id=:id]', [':id' => $id]);
     $this->assertNotEmpty($elements, $message);
@@ -1110,7 +1110,7 @@ protected function assertOptionWithDrupalSelector($drupal_selector, $option, $me
    * @return bool
    *   TRUE on pass.
    */
-  protected function assertNoOption($id, $option, $message = '') {
+  protected function assertNoOption($id, $option, $message = ''): bool {
     $message = $message ? $message : new FormattableMarkup('Option @option for field @id does not exist.', ['@option' => $option, '@id' => $id]);
     $selects = $this->xpath('//select[@id=:id]', [':id' => $id]);
     $options = $this->xpath('//select[@id=:id]//option[@value=:option]', [':id' => $id, ':option' => $option]);
@@ -1137,7 +1137,7 @@ protected function assertNoOption($id, $option, $message = '') {
    *
    * @todo $id is unusable. Replace with $name.
    */
-  protected function assertOptionSelected($id, $option, $message = '') {
+  protected function assertOptionSelected($id, $option, $message = ''): bool {
     $message = $message ? $message : new FormattableMarkup('Option @option for field @id is selected.', ['@option' => $option, '@id' => $id]);
     $elements = $this->xpath('//select[@id=:id]//option[@value=:option]', [':id' => $id, ':option' => $option]);
     $this->assertNotEmpty($elements, $message);
@@ -1163,7 +1163,7 @@ protected function assertOptionSelected($id, $option, $message = '') {
    *
    * @todo $id is unusable. Replace with $name.
    */
-  protected function assertOptionSelectedWithDrupalSelector($drupal_selector, $option, $message = '') {
+  protected function assertOptionSelectedWithDrupalSelector($drupal_selector, $option, $message = ''): bool {
     $message = $message ? $message : new FormattableMarkup('Option @option for field @data_drupal_selector is selected.', ['@option' => $option, '@data_drupal_selector' => $drupal_selector]);
     $elements = $this->xpath('//select[@data-drupal-selector=:data_drupal_selector]//option[@value=:option]', [':data_drupal_selector' => $drupal_selector, ':option' => $option]);
     $this->assertNotEmpty($elements, $message);
@@ -1187,7 +1187,7 @@ protected function assertOptionSelectedWithDrupalSelector($drupal_selector, $opt
    * @return bool
    *   TRUE on pass.
    */
-  protected function assertNoOptionSelected($id, $option, $message = '') {
+  protected function assertNoOptionSelected($id, $option, $message = ''): bool {
     $message = $message ? $message : new FormattableMarkup('Option @option for field @id is not selected.', ['@option' => $option, '@id' => $id]);
     $elements = $this->xpath('//select[@id=:id]//option[@value=:option]', [':id' => $id, ':option' => $option]);
     $this->assertNotEmpty($elements, $message);
@@ -1252,7 +1252,7 @@ protected function assertNoField($field, $message = '') {
    * @return bool
    *   TRUE on pass.
    */
-  protected function assertNoDuplicateIds($message = '', $group = NULL, $ids_to_skip = []) {
+  protected function assertNoDuplicateIds($message = '', $group = NULL, $ids_to_skip = []): bool {
     $status = TRUE;
     foreach ($this->xpath('//*[@id]') as $element) {
       $id = (string) $element['id'];
diff --git a/core/tests/Drupal/KernelTests/Core/Entity/ContentEntityChangedTest.php b/core/tests/Drupal/KernelTests/Core/Entity/ContentEntityChangedTest.php
index 7824248bf55b9543035a7c6412db62e6c20ff4a3..e4427af0b123e442a6c36ff2e1f3793c8519cd72 100644
--- a/core/tests/Drupal/KernelTests/Core/Entity/ContentEntityChangedTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Entity/ContentEntityChangedTest.php
@@ -504,7 +504,7 @@ public function testChangedSyncing(): void {
    * @return bool
    *   The flag value.
    */
-  protected function getRevisionTranslationAffectedFlag(EntityTestMulRevChanged $entity) {
+  protected function getRevisionTranslationAffectedFlag(EntityTestMulRevChanged $entity): bool {
     $query = $this->mulRevChangedStorage->getQuery()->accessCheck(FALSE);
     $ids = $query->condition('revision_translation_affected', 1, '=', $entity->language()->getId())->execute();
     $id = reset($ids);
diff --git a/core/tests/Drupal/Tests/Component/HttpFoundation/SecuredRedirectResponseTest.php b/core/tests/Drupal/Tests/Component/HttpFoundation/SecuredRedirectResponseTest.php
index c6a19a35b99bd166529f9f4df03c83a9bac2679c..869733a54b2c10d8bcd7990970da3193eccba3f5 100644
--- a/core/tests/Drupal/Tests/Component/HttpFoundation/SecuredRedirectResponseTest.php
+++ b/core/tests/Drupal/Tests/Component/HttpFoundation/SecuredRedirectResponseTest.php
@@ -49,7 +49,7 @@ class SecuredRedirectStub extends SecuredRedirectResponse {
   /**
    * {@inheritdoc}
    */
-  protected function isSafe($url) {
+  protected function isSafe($url): bool {
     // Empty implementation for testing.
     return TRUE;
   }
diff --git a/core/tests/Drupal/Tests/Core/Command/QuickStartTest.php b/core/tests/Drupal/Tests/Core/Command/QuickStartTest.php
index 74139e1b9baca0c73912c3bca90b76f3ddabeac4..17c12d2d394e0545b3164a4af951bef1c4c30e7b 100644
--- a/core/tests/Drupal/Tests/Core/Command/QuickStartTest.php
+++ b/core/tests/Drupal/Tests/Core/Command/QuickStartTest.php
@@ -273,7 +273,7 @@ public function testServerWithNoInstall(): void {
    *
    * @see \Drupal\Core\File\FileSystemInterface::deleteRecursive()
    */
-  protected function fileUnmanagedDeleteRecursive($path, $callback = NULL) {
+  protected function fileUnmanagedDeleteRecursive($path, $callback = NULL): bool {
     if (isset($callback)) {
       call_user_func($callback, $path);
     }
diff --git a/core/tests/Drupal/Tests/Core/EventSubscriber/FinalExceptionSubscriberTest.php b/core/tests/Drupal/Tests/Core/EventSubscriber/FinalExceptionSubscriberTest.php
index b871ebedeac8a4f99a762fb4bd3515438f62d9e9..6193d7ccdce3a8b90c09ade41affa23b8b7b8545 100644
--- a/core/tests/Drupal/Tests/Core/EventSubscriber/FinalExceptionSubscriberTest.php
+++ b/core/tests/Drupal/Tests/Core/EventSubscriber/FinalExceptionSubscriberTest.php
@@ -48,7 +48,7 @@ public function testOnExceptionWithUnknownFormat(): void {
 
 class TestDefaultExceptionSubscriber extends FinalExceptionSubscriber {
 
-  protected function isErrorDisplayable($error) {
+  protected function isErrorDisplayable($error): bool {
     return TRUE;
   }
 
@@ -56,7 +56,7 @@ protected function simplifyFileInError($error) {
     return $error;
   }
 
-  protected function isErrorLevelVerbose() {
+  protected function isErrorLevelVerbose(): bool {
     return TRUE;
   }