From fb2b8c49e55c7058696636b392d0b1cf3e4415d9 Mon Sep 17 00:00:00 2001
From: Sweetchuck <Sweetchuck@23728.no-reply.drupal.org>
Date: Sun, 20 Nov 2022 20:23:20 +0100
Subject: [PATCH] WIP

---
 .../Drupal/Core/Config/StorableConfigBase.php |   2 -
 .../Drupal/Core/Config/TypedConfigManager.php |  38 ++--
 .../Drupal/Core/Entity/Query/Sql/Tables.php   |   4 +-
 .../Sql/SqlContentEntityStorageSchema.php     |   6 -
 ...duleRequiredByThemesUninstallValidator.php |   6 +-
 .../lib/Drupal/Core/Render/Element/Select.php |  47 ++---
 core/lib/Drupal/Core/Render/Element/Table.php |   2 +
 .../Core/Render/Element/Tableselect.php       |   2 +
 core/lib/Drupal/Core/Render/theme.api.php     |   3 -
 core/lib/Drupal/Core/Routing/Router.php       |   2 +
 .../Drupal/Core/TempStore/SharedTempStore.php |  10 +-
 .../Drupal/Core/Theme/ThemeInitialization.php |   2 +
 .../lib/Drupal/Core/Theme/ThemeNegotiator.php |   2 +
 .../TypedData/Plugin/DataType/ItemList.php    |   7 +-
 .../TypedData/Plugin/DataType/TimeSpan.php    |  10 +-
 .../TypedData/Plugin/DataType/Timestamp.php   |   6 +-
 .../lib/Drupal/Core/Utility/ThemeRegistry.php |   2 +
 .../views/argument_default/TopLevelBook.php   |   2 +
 .../src/Plugin/CKEditor5PluginManager.php     |   2 +
 .../src/Plugin/views/argument/UserUid.php     |   2 +
 core/modules/forum/src/ForumManager.php       |  38 ++--
 core/modules/jsonapi/jsonapi.api.php          |   7 +-
 core/modules/jsonapi/jsonapi.module           |   7 +-
 .../Kernel/LayoutEntityHelperTraitTest.php    |   2 +
 core/modules/locale/locale.compare.inc        |   3 -
 .../locale/src/StringDatabaseStorage.php      |  24 ++-
 .../tests/src/Unit/LocaleLookupTest.php       |   2 +
 .../Discovery/StaticReflectionParser.php      |   7 +-
 core/modules/migrate/src/Row.php              |   5 +-
 .../modules/node/src/Plugin/views/row/Rss.php |   4 +-
 core/modules/search/search.module             |   2 +
 .../serialization/serialization.module        |   2 +
 .../settings_tray/settings_tray.module        |   2 +
 core/modules/shortcut/shortcut.api.php        |   4 +-
 core/modules/shortcut/shortcut.module         |   2 +
 core/modules/sqlite/sqlite.module             |   2 +
 core/modules/statistics/statistics.module     |   4 +
 core/modules/syslog/syslog.module             |   2 +
 core/modules/system/system.module             |   4 +
 .../src/Theme/TestThemeNegotiator.php         |   8 +-
 .../modules/system_test/system_test.module    |   2 +
 .../PathBasedBreadcrumbBuilderTest.php        |   9 +-
 .../Routing/VocabularyRouteProvider.php       |   2 +
 .../migrate/source/d7/TermTranslation.php     |   2 +
 .../src/Plugin/views/argument_default/Tid.php |   2 +
 core/modules/taxonomy/taxonomy.module         |   2 +
 core/modules/telephone/telephone.module       |   2 +
 core/modules/text/text.module                 |   2 +
 core/modules/toolbar/toolbar.module           |   2 +
 core/modules/tour/src/TipPluginBase.php       |   4 +-
 core/modules/tour/tour.module                 |   2 +
 core/modules/tracker/tracker.module           |   2 +
 core/modules/update/update.manager.inc        |   2 +
 core/modules/update/update.module             |   2 +
 .../Plugin/views/argument_default/User.php    |   2 +
 .../user/src/Plugin/views/field/UserData.php  |   6 +-
 core/modules/user/user.install                |   2 +
 core/modules/user/user.module                 |   9 +-
 .../src/Plugin/views/area/TextCustom.php      |   6 +-
 .../views/argument/ArgumentPluginBase.php     |  11 +-
 .../views/src/Plugin/views/query/Sql.php      |   6 +-
 .../Plugin/views/style/StylePluginBase.php    |  32 ++--
 core/modules/views/src/ViewExecutable.php     |  50 ++---
 .../views_entity_test.module                  |   4 +-
 core/modules/views/views.module               |   2 +
 core/modules/views_ui/views_ui.module         |   2 +
 core/modules/workflows/workflows.module       |   2 +
 core/modules/workspaces/workspaces.module     |   2 +
 core/phpstan-baseline.neon                    | 180 ------------------
 .../Update/UpdatePathTestBase.php             |   2 +-
 .../KernelTests/Core/Database/QueryTest.php   |   2 +
 .../Tests/Core/Asset/LibraryDiscoveryTest.php |   7 +-
 .../Tests/Core/Command/QuickStartTest.php     |   4 +
 .../Core/Entity/EntityFieldManagerTest.php    |   4 +-
 .../Tests/Core/Utility/LinkGeneratorTest.php  |   2 +
 75 files changed, 291 insertions(+), 371 deletions(-)

diff --git a/core/lib/Drupal/Core/Config/StorableConfigBase.php b/core/lib/Drupal/Core/Config/StorableConfigBase.php
index f3202a764441..ae521919d00a 100644
--- a/core/lib/Drupal/Core/Config/StorableConfigBase.php
+++ b/core/lib/Drupal/Core/Config/StorableConfigBase.php
@@ -145,8 +145,6 @@ protected function getSchemaWrapper() {
    * @param mixed $value
    *   Value to associate with the key.
    *
-   * @return null
-   *
    * @throws \Drupal\Core\Config\UnsupportedDataTypeConfigException
    *   If the value is unsupported in configuration.
    */
diff --git a/core/lib/Drupal/Core/Config/TypedConfigManager.php b/core/lib/Drupal/Core/Config/TypedConfigManager.php
index dcb328dc5d79..6e193fc50605 100644
--- a/core/lib/Drupal/Core/Config/TypedConfigManager.php
+++ b/core/lib/Drupal/Core/Config/TypedConfigManager.php
@@ -246,24 +246,26 @@ public function clearCachedDefinitions() {
   protected function getFallbackName($name) {
     // Check for definition of $name with filesystem marker.
     $replaced = preg_replace('/([^\.:]+)([\.:\*]*)$/', '*\2', $name);
-    if ($replaced != $name) {
-      if (isset($this->definitions[$replaced])) {
-        return $replaced;
-      }
-      else {
-        // No definition for this level. Collapse multiple wildcards to a single
-        // wildcard to see if there is a greedy match. For example,
-        // breakpoint.breakpoint.*.* becomes
-        // breakpoint.breakpoint.*
-        $one_star = preg_replace('/\.([:\.\*]*)$/', '.*', $replaced);
-        if ($one_star != $replaced && isset($this->definitions[$one_star])) {
-          return $one_star;
-        }
-        // Check for next level. For example, if breakpoint.breakpoint.* has
-        // been checked and no match found then check breakpoint.*.*
-        return $this->getFallbackName($replaced);
-      }
+    if ($replaced === $name) {
+      return NULL;
+    }
+
+    if (isset($this->definitions[$replaced])) {
+      return $replaced;
+    }
+
+    // No definition for this level. Collapse multiple wildcards to a single
+    // wildcard to see if there is a greedy match. For example,
+    // "breakpoint.breakpoint.*.*" becomes
+    // "breakpoint.breakpoint.*".
+    $one_star = preg_replace('/\.([:\.\*]*)$/', '.*', $replaced);
+    if ($one_star != $replaced && isset($this->definitions[$one_star])) {
+      return $one_star;
     }
+
+    // Check for next level. For example, if breakpoint.breakpoint.* has
+    // been checked and no match found then check "breakpoint.*.*".
+    return $this->getFallbackName($replaced);
   }
 
   /**
@@ -360,6 +362,8 @@ protected function replaceVariable($value, $data) {
         }
       }
     }
+
+    return $value;
   }
 
   /**
diff --git a/core/lib/Drupal/Core/Entity/Query/Sql/Tables.php b/core/lib/Drupal/Core/Entity/Query/Sql/Tables.php
index 5e5dfb815c82..9ffdb4596d29 100644
--- a/core/lib/Drupal/Core/Entity/Query/Sql/Tables.php
+++ b/core/lib/Drupal/Core/Entity/Query/Sql/Tables.php
@@ -315,9 +315,7 @@ public function addField($field, $type, $langcode) {
    * {@inheritdoc}
    */
   public function isFieldCaseSensitive($field_name) {
-    if (isset($this->caseSensitiveFields[$field_name])) {
-      return $this->caseSensitiveFields[$field_name];
-    }
+    return $this->caseSensitiveFields[$field_name] ?? NULL;
   }
 
   /**
diff --git a/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorageSchema.php b/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorageSchema.php
index 48adc9772a3d..7088b214601d 100644
--- a/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorageSchema.php
+++ b/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorageSchema.php
@@ -1455,9 +1455,6 @@ protected function addTableDefaults(&$schema) {
    *   The entity type.
    * @param array $schema
    *   The table schema, passed by reference.
-   *
-   * @return array
-   *   A partial schema array for the base table.
    */
   protected function processDataTable(ContentEntityTypeInterface $entity_type, array &$schema) {
     // Marking the respective fields as NOT NULL makes the indexes more
@@ -1472,9 +1469,6 @@ protected function processDataTable(ContentEntityTypeInterface $entity_type, arr
    *   The entity type.
    * @param array $schema
    *   The table schema, passed by reference.
-   *
-   * @return array
-   *   A partial schema array for the base table.
    */
   protected function processRevisionDataTable(ContentEntityTypeInterface $entity_type, array &$schema) {
     // Marking the respective fields as NOT NULL makes the indexes more
diff --git a/core/lib/Drupal/Core/Extension/ModuleRequiredByThemesUninstallValidator.php b/core/lib/Drupal/Core/Extension/ModuleRequiredByThemesUninstallValidator.php
index 1e98447303f9..b1882a91112b 100644
--- a/core/lib/Drupal/Core/Extension/ModuleRequiredByThemesUninstallValidator.php
+++ b/core/lib/Drupal/Core/Extension/ModuleRequiredByThemesUninstallValidator.php
@@ -96,9 +96,9 @@ public function validateConfigImport(string $module, StorageInterface $source_st
   protected function getThemesDependingOnModule($module) {
     $installed_themes = $this->themeExtensionList->getAllInstalledInfo();
     $themes_depending_on_module = array_map(function ($theme) use ($module) {
-      if (in_array($module, $theme['dependencies'])) {
-        return $theme['name'];
-      }
+      return in_array($module, $theme['dependencies']) ?
+        $theme['name']
+        : NULL;
     }, $installed_themes);
 
     return array_filter($themes_depending_on_module);
diff --git a/core/lib/Drupal/Core/Render/Element/Select.php b/core/lib/Drupal/Core/Render/Element/Select.php
index 596ad133d10c..a9f7408d1b34 100644
--- a/core/lib/Drupal/Core/Render/Element/Select.php
+++ b/core/lib/Drupal/Core/Render/Element/Select.php
@@ -162,31 +162,32 @@ public static function processSelect(&$element, FormStateInterface $form_state,
    * {@inheritdoc}
    */
   public static function valueCallback(&$element, $input, FormStateInterface $form_state) {
-    if ($input !== FALSE) {
-      if (isset($element['#multiple']) && $element['#multiple']) {
-        // If an enabled multi-select submits NULL, it means all items are
-        // unselected. A disabled multi-select always submits NULL, and the
-        // default value should be used.
-        if (empty($element['#disabled'])) {
-          return (is_array($input)) ? array_combine($input, $input) : [];
-        }
-        else {
-          return (isset($element['#default_value']) && is_array($element['#default_value'])) ? $element['#default_value'] : [];
-        }
-      }
-      // Non-multiple select elements may have an empty option prepended to them
-      // (see \Drupal\Core\Render\Element\Select::processSelect()). When this
-      // occurs, usually #empty_value is an empty string, but some forms set
-      // #empty_value to integer 0 or some other non-string constant. PHP
-      // receives all submitted form input as strings, but if the empty option
-      // is selected, set the value to match the empty value exactly.
-      elseif (isset($element['#empty_value']) && $input === (string) $element['#empty_value']) {
-        return $element['#empty_value'];
-      }
-      else {
-        return $input;
+    if ($input === FALSE) {
+      return NULL;
+    }
+
+    if (isset($element['#multiple']) && $element['#multiple']) {
+      // If an enabled multi-select submits NULL, it means all items are
+      // unselected. A disabled multi-select always submits NULL, and the
+      // default value should be used.
+      if (empty($element['#disabled'])) {
+        return (is_array($input)) ? array_combine($input, $input) : [];
       }
+
+      return (isset($element['#default_value']) && is_array($element['#default_value'])) ? $element['#default_value'] : [];
+    }
+
+    // Non-multiple select elements may have an empty option prepended to them
+    // (see \Drupal\Core\Render\Element\Select::processSelect()). When this
+    // occurs, usually #empty_value is an empty string, but some forms set
+    // #empty_value to integer 0 or some other non-string constant. PHP
+    // receives all submitted form input as strings, but if the empty option
+    // is selected, set the value to match the empty value exactly.
+    if (isset($element['#empty_value']) && $input === (string) $element['#empty_value']) {
+      return $element['#empty_value'];
     }
+
+    return $input;
   }
 
   /**
diff --git a/core/lib/Drupal/Core/Render/Element/Table.php b/core/lib/Drupal/Core/Render/Element/Table.php
index ef650c9df619..a658a1e882aa 100644
--- a/core/lib/Drupal/Core/Render/Element/Table.php
+++ b/core/lib/Drupal/Core/Render/Element/Table.php
@@ -115,6 +115,8 @@ public static function valueCallback(&$element, $input, FormStateInterface $form
         return is_array($input) ? array_combine($input, $input) : [];
       }
     }
+
+    return NULL;
   }
 
   /**
diff --git a/core/lib/Drupal/Core/Render/Element/Tableselect.php b/core/lib/Drupal/Core/Render/Element/Tableselect.php
index 6258500c0026..8eb2c87fe6fc 100644
--- a/core/lib/Drupal/Core/Render/Element/Tableselect.php
+++ b/core/lib/Drupal/Core/Render/Element/Tableselect.php
@@ -102,6 +102,8 @@ public static function valueCallback(&$element, $input, FormStateInterface $form
         return is_array($input) ? array_combine($input, $input) : [];
       }
     }
+
+    return NULL;
   }
 
   /**
diff --git a/core/lib/Drupal/Core/Render/theme.api.php b/core/lib/Drupal/Core/Render/theme.api.php
index cd33aecbc29b..1ce85efb9203 100644
--- a/core/lib/Drupal/Core/Render/theme.api.php
+++ b/core/lib/Drupal/Core/Render/theme.api.php
@@ -688,9 +688,6 @@ function hook_theme_suggestions_HOOK(array $variables) {
  *   (in this case 'node__article') is available in
  *   $variables['theme_hook_original'].
  *
- * @return array
- *   An array of theme suggestions.
- *
  * @see hook_theme_suggestions_HOOK_alter()
  */
 function hook_theme_suggestions_alter(array &$suggestions, array $variables, $hook) {
diff --git a/core/lib/Drupal/Core/Routing/Router.php b/core/lib/Drupal/Core/Routing/Router.php
index bef84e9be844..9e100971f3c4 100644
--- a/core/lib/Drupal/Core/Routing/Router.php
+++ b/core/lib/Drupal/Core/Routing/Router.php
@@ -237,6 +237,8 @@ protected function doMatchCollection($pathinfo, RouteCollection $routes, $case_s
 
       return $attributes;
     }
+
+    return NULL;
   }
 
   /**
diff --git a/core/lib/Drupal/Core/TempStore/SharedTempStore.php b/core/lib/Drupal/Core/TempStore/SharedTempStore.php
index 089941c8de04..96a843a2f413 100644
--- a/core/lib/Drupal/Core/TempStore/SharedTempStore.php
+++ b/core/lib/Drupal/Core/TempStore/SharedTempStore.php
@@ -118,13 +118,15 @@ public function __construct(KeyValueStoreExpirableInterface $storage, LockBacken
    * @param string $key
    *   The key of the data to retrieve.
    *
-   * @return mixed
+   * @return null|mixed
    *   The data associated with the key, or NULL if the key does not exist.
    */
   public function get($key) {
     if ($object = $this->storage->get($key)) {
       return $object->data;
     }
+
+    return NULL;
   }
 
   /**
@@ -135,13 +137,15 @@ public function get($key) {
    * @param string $key
    *   The key of the data to retrieve.
    *
-   * @return mixed
+   * @return null|mixed
    *   The data associated with the key, or NULL if the key does not exist.
    */
   public function getIfOwner($key) {
     if (($object = $this->storage->get($key)) && ($object->owner == $this->owner)) {
       return $object->data;
     }
+
+    return NULL;
   }
 
   /**
@@ -244,6 +248,8 @@ public function getMetadata($key) {
       unset($object->data);
       return new Lock($object->owner, $object->updated);
     }
+
+    return NULL;
   }
 
   /**
diff --git a/core/lib/Drupal/Core/Theme/ThemeInitialization.php b/core/lib/Drupal/Core/Theme/ThemeInitialization.php
index 18592da2112d..5d613a3bb619 100644
--- a/core/lib/Drupal/Core/Theme/ThemeInitialization.php
+++ b/core/lib/Drupal/Core/Theme/ThemeInitialization.php
@@ -294,6 +294,8 @@ protected function resolveStyleSheetPlaceholders($css_file) {
     if (isset($extensions[$token])) {
       return str_replace($token_candidate, $extensions[$token]->getPath(), $css_file);
     }
+
+    return NULL;
   }
 
 }
diff --git a/core/lib/Drupal/Core/Theme/ThemeNegotiator.php b/core/lib/Drupal/Core/Theme/ThemeNegotiator.php
index 18b618cedbd7..d4b3077bbf56 100644
--- a/core/lib/Drupal/Core/Theme/ThemeNegotiator.php
+++ b/core/lib/Drupal/Core/Theme/ThemeNegotiator.php
@@ -71,6 +71,8 @@ public function determineActiveTheme(RouteMatchInterface $route_match) {
         }
       }
     }
+
+    return NULL;
   }
 
 }
diff --git a/core/lib/Drupal/Core/TypedData/Plugin/DataType/ItemList.php b/core/lib/Drupal/Core/TypedData/Plugin/DataType/ItemList.php
index 18d68267a456..baf110ef7d51 100644
--- a/core/lib/Drupal/Core/TypedData/Plugin/DataType/ItemList.php
+++ b/core/lib/Drupal/Core/TypedData/Plugin/DataType/ItemList.php
@@ -275,9 +275,10 @@ public function filter($callback) {
         if (call_user_func($callback, $item)) {
           return TRUE;
         }
-        else {
-          $removed = TRUE;
-        }
+
+        $removed = TRUE;
+
+        return FALSE;
       });
       if ($removed) {
         $this->rekey();
diff --git a/core/lib/Drupal/Core/TypedData/Plugin/DataType/TimeSpan.php b/core/lib/Drupal/Core/TypedData/Plugin/DataType/TimeSpan.php
index d0cb7fe66f15..04e1f7ae5ba1 100644
--- a/core/lib/Drupal/Core/TypedData/Plugin/DataType/TimeSpan.php
+++ b/core/lib/Drupal/Core/TypedData/Plugin/DataType/TimeSpan.php
@@ -26,11 +26,11 @@ class TimeSpan extends IntegerData implements DurationInterface {
    * {@inheritdoc}
    */
   public function getDuration() {
-    if ($this->value) {
-      // Keep the duration in seconds as there is generally no valid way to
-      // convert it to days, months or years.
-      return new \DateInterval('PT' . $this->value . 'S');
-    }
+    // Keep the duration in seconds as there is generally no valid way to
+    // convert it to days, months or years.
+    return $this->value ?
+      new \DateInterval('PT' . $this->value . 'S')
+      : NULL;
   }
 
   /**
diff --git a/core/lib/Drupal/Core/TypedData/Plugin/DataType/Timestamp.php b/core/lib/Drupal/Core/TypedData/Plugin/DataType/Timestamp.php
index 60cd9b423b6d..c17911d73b0e 100644
--- a/core/lib/Drupal/Core/TypedData/Plugin/DataType/Timestamp.php
+++ b/core/lib/Drupal/Core/TypedData/Plugin/DataType/Timestamp.php
@@ -26,9 +26,9 @@ class Timestamp extends IntegerData implements DateTimeInterface {
    * {@inheritdoc}
    */
   public function getDateTime() {
-    if (isset($this->value)) {
-      return DrupalDateTime::createFromTimestamp($this->value);
-    }
+    return isset($this->value) ?
+      DrupalDateTime::createFromTimestamp($this->value)
+      : NULL;
   }
 
   /**
diff --git a/core/lib/Drupal/Core/Utility/ThemeRegistry.php b/core/lib/Drupal/Core/Utility/ThemeRegistry.php
index c7da9e43051e..a07720b85aca 100644
--- a/core/lib/Drupal/Core/Utility/ThemeRegistry.php
+++ b/core/lib/Drupal/Core/Utility/ThemeRegistry.php
@@ -114,6 +114,8 @@ public function get($key) {
     elseif (array_key_exists($key, $this->storage)) {
       return $this->resolveCacheMiss($key);
     }
+
+    return NULL;
   }
 
   /**
diff --git a/core/modules/book/src/Plugin/views/argument_default/TopLevelBook.php b/core/modules/book/src/Plugin/views/argument_default/TopLevelBook.php
index 36a6f79a5ca3..e548d50b896f 100644
--- a/core/modules/book/src/Plugin/views/argument_default/TopLevelBook.php
+++ b/core/modules/book/src/Plugin/views/argument_default/TopLevelBook.php
@@ -68,6 +68,8 @@ public function getArgument() {
         return $node->book['bid'];
       }
     }
+
+    return NULL;
   }
 
 }
diff --git a/core/modules/ckeditor5/src/Plugin/CKEditor5PluginManager.php b/core/modules/ckeditor5/src/Plugin/CKEditor5PluginManager.php
index 5f900126b1b1..25a509f64339 100644
--- a/core/modules/ckeditor5/src/Plugin/CKEditor5PluginManager.php
+++ b/core/modules/ckeditor5/src/Plugin/CKEditor5PluginManager.php
@@ -445,6 +445,8 @@ protected function mergeDefinitionValues(string $get_method, array $definitions)
       if ($definition->$has_method()) {
         return $definition->$get_method();
       }
+
+      return NULL;
     }, $definitions));
     return array_reduce($per_plugin, function (array $result, $current): array {
       return is_array($current) && is_array(reset($current))
diff --git a/core/modules/comment/src/Plugin/views/argument/UserUid.php b/core/modules/comment/src/Plugin/views/argument/UserUid.php
index e6c063b9efea..ace7ab47afa0 100644
--- a/core/modules/comment/src/Plugin/views/argument/UserUid.php
+++ b/core/modules/comment/src/Plugin/views/argument/UserUid.php
@@ -75,6 +75,8 @@ protected function defaultActions($which = NULL) {
     if ($which != 'summary asc' && $which != 'summary desc') {
       return parent::defaultActions($which);
     }
+
+    return NULL;
   }
 
   public function query($group_by = FALSE) {
diff --git a/core/modules/forum/src/ForumManager.php b/core/modules/forum/src/ForumManager.php
index a21afdf04761..bbf1b739ee4a 100644
--- a/core/modules/forum/src/ForumManager.php
+++ b/core/modules/forum/src/ForumManager.php
@@ -289,22 +289,32 @@ public function getTopics($tid, AccountInterface $account) {
    *   An array with the following values:
    *   - field: A field for an SQL query.
    *   - sort: 'asc' or 'desc'.
+   *
+   * @see NEWEST_FIRST
+   * @see OLDEST_FIRST
+   * @see MOST_POPULAR_FIRST
+   * @see LEAST_POPULAR_FIRST
    */
   protected function getTopicOrder($sortby) {
-    switch ($sortby) {
-      case static::NEWEST_FIRST:
-        return ['field' => 'f.last_comment_timestamp', 'sort' => 'desc'];
-
-      case static::OLDEST_FIRST:
-        return ['field' => 'f.last_comment_timestamp', 'sort' => 'asc'];
-
-      case static::MOST_POPULAR_FIRST:
-        return ['field' => 'f.comment_count', 'sort' => 'desc'];
-
-      case static::LEAST_POPULAR_FIRST:
-        return ['field' => 'f.comment_count', 'sort' => 'asc'];
-
-    }
+    return match ($sortby) {
+      static::OLDEST_FIRST => [
+        'field' => 'f.last_comment_timestamp',
+        'sort' => 'asc',
+      ],
+      static::MOST_POPULAR_FIRST => [
+        'field' => 'f.comment_count',
+        'sort' => 'desc',
+      ],
+      static::LEAST_POPULAR_FIRST => [
+        'field' => 'f.comment_count',
+        'sort' => 'asc',
+      ],
+      // NEWEST_FIRST.
+      default => [
+        'field' => 'f.last_comment_timestamp',
+        'sort' => 'desc',
+      ],
+    };
   }
 
   /**
diff --git a/core/modules/jsonapi/jsonapi.api.php b/core/modules/jsonapi/jsonapi.api.php
index 208b169bbe93..5519819ea4ba 100644
--- a/core/modules/jsonapi/jsonapi.api.php
+++ b/core/modules/jsonapi/jsonapi.api.php
@@ -271,13 +271,14 @@
  * @see hook_jsonapi_ENTITY_TYPE_filter_access()
  */
 function hook_jsonapi_entity_filter_access(\Drupal\Core\Entity\EntityTypeInterface $entity_type, \Drupal\Core\Session\AccountInterface $account) {
+  $results = [];
   // For every entity type that has an admin permission, allow access to filter
   // by all entities of that type to users with that permission.
   if ($admin_permission = $entity_type->getAdminPermission()) {
-    return ([
-      JSONAPI_FILTER_AMONG_ALL => AccessResult::allowedIfHasPermission($account, $admin_permission),
-    ]);
+    $results[JSONAPI_FILTER_AMONG_ALL] = AccessResult::allowedIfHasPermission($account, $admin_permission);
   }
+
+  return $results;
 }
 
 /**
diff --git a/core/modules/jsonapi/jsonapi.module b/core/modules/jsonapi/jsonapi.module
index 804e78fd6437..f2909e491685 100644
--- a/core/modules/jsonapi/jsonapi.module
+++ b/core/modules/jsonapi/jsonapi.module
@@ -163,16 +163,17 @@ function jsonapi_entity_delete(EntityInterface $entity) {
  * Implements hook_jsonapi_entity_filter_access().
  */
 function jsonapi_jsonapi_entity_filter_access(EntityTypeInterface $entity_type, AccountInterface $account) {
+  $results = [];
   // All core entity types and most or all contrib entity types allow users
   // with the entity type's administrative permission to view all of the
   // entities, so enable similarly permissive filtering to those users as well.
   // A contrib module may override this decision by returning
   // AccessResult::forbidden() from its implementation of this hook.
   if ($admin_permission = $entity_type->getAdminPermission()) {
-    return ([
-      JSONAPI_FILTER_AMONG_ALL => AccessResult::allowedIfHasPermission($account, $admin_permission),
-    ]);
+    $results[JSONAPI_FILTER_AMONG_ALL] = AccessResult::allowedIfHasPermission($account, $admin_permission);
   }
+
+  return $results;
 }
 
 /**
diff --git a/core/modules/layout_builder/tests/src/Kernel/LayoutEntityHelperTraitTest.php b/core/modules/layout_builder/tests/src/Kernel/LayoutEntityHelperTraitTest.php
index df528c00628b..6575bdd80e32 100644
--- a/core/modules/layout_builder/tests/src/Kernel/LayoutEntityHelperTraitTest.php
+++ b/core/modules/layout_builder/tests/src/Kernel/LayoutEntityHelperTraitTest.php
@@ -208,6 +208,8 @@ public function testOriginalEntityUsesDefaultStorage($entity_storages, $is_new,
         $entity = $contexts['entity']->getContextData()->getValue();
         return $storages[$entity_storages[$entity->getName()]];
       }
+
+      return NULL;
     });
 
     $this->container->set('plugin.manager.layout_builder.section_storage', $section_storage_manager->reveal());
diff --git a/core/modules/locale/locale.compare.inc b/core/modules/locale/locale.compare.inc
index b07c5360c70b..5a5a9c165ad5 100644
--- a/core/modules/locale/locale.compare.inc
+++ b/core/modules/locale/locale.compare.inc
@@ -177,9 +177,6 @@ function locale_translation_default_translation_server() {
  * @param array $langcodes
  *   Array of language codes. Defaults to all translatable languages.
  *
- * @return array
- *   Available sources indexed by project and language.
- *
  * @todo Return batch or NULL.
  */
 function locale_translation_check_projects($projects = [], $langcodes = []) {
diff --git a/core/modules/locale/src/StringDatabaseStorage.php b/core/modules/locale/src/StringDatabaseStorage.php
index 74e94fca5d16..3bf84762f158 100644
--- a/core/modules/locale/src/StringDatabaseStorage.php
+++ b/core/modules/locale/src/StringDatabaseStorage.php
@@ -59,11 +59,14 @@ public function findString(array $conditions) {
       ->execute()
       ->fetchAssoc();
 
-    if (!empty($values)) {
-      $string = new SourceString($values);
-      $string->setStorage($this);
-      return $string;
+    if (!$values) {
+      return NULL;
     }
+
+    $string = new SourceString($values);
+    $string->setStorage($this);
+
+    return $string;
   }
 
   /**
@@ -74,12 +77,15 @@ public function findTranslation(array $conditions) {
       ->execute()
       ->fetchAssoc();
 
-    if (!empty($values)) {
-      $string = new TranslationString($values);
-      $this->checkVersion($string, \Drupal::VERSION);
-      $string->setStorage($this);
-      return $string;
+    if (!$values) {
+      return NULL;
     }
+
+    $string = new TranslationString($values);
+    $this->checkVersion($string, \Drupal::VERSION);
+    $string->setStorage($this);
+
+    return $string;
   }
 
   /**
diff --git a/core/modules/locale/tests/src/Unit/LocaleLookupTest.php b/core/modules/locale/tests/src/Unit/LocaleLookupTest.php
index bcc09c250cfa..d2a229d87e33 100644
--- a/core/modules/locale/tests/src/Unit/LocaleLookupTest.php
+++ b/core/modules/locale/tests/src/Unit/LocaleLookupTest.php
@@ -306,6 +306,8 @@ public function testFixOldPluralStyleTranslations($translations, $langcode, $str
           case 'by':
             return ['ru'];
         }
+
+        return NULL;
       });
     $this->cache->expects($this->once())
       ->method('get')
diff --git a/core/modules/migrate/src/Plugin/Discovery/StaticReflectionParser.php b/core/modules/migrate/src/Plugin/Discovery/StaticReflectionParser.php
index a26a2c1e422a..61abb5f0dbae 100644
--- a/core/modules/migrate/src/Plugin/Discovery/StaticReflectionParser.php
+++ b/core/modules/migrate/src/Plugin/Discovery/StaticReflectionParser.php
@@ -32,9 +32,10 @@ public static function getParentParser(BaseStaticReflectionParser $parser, $find
     // Ensure the class has been parsed before accessing the parentClassName
     // property.
     $parser->parse();
-    if ($parser->parentClassName) {
-      return new static($parser->parentClassName, $finder, $parser->classAnnotationOptimize);
-    }
+
+    return $parser->parentClassName ?
+      new static($parser->parentClassName, $finder, $parser->classAnnotationOptimize)
+      : NULL;
   }
 
 }
diff --git a/core/modules/migrate/src/Row.php b/core/modules/migrate/src/Row.php
index 3d961902bcde..269bef8f08b2 100644
--- a/core/modules/migrate/src/Row.php
+++ b/core/modules/migrate/src/Row.php
@@ -151,9 +151,8 @@ public function hasSourceProperty($property) {
    */
   public function getSourceProperty($property) {
     $return = NestedArray::getValue($this->source, explode(static::PROPERTY_SEPARATOR, $property), $key_exists);
-    if ($key_exists) {
-      return $return;
-    }
+
+    return $key_exists ? $return : NULL;
   }
 
   /**
diff --git a/core/modules/node/src/Plugin/views/row/Rss.php b/core/modules/node/src/Plugin/views/row/Rss.php
index a8fe007502fc..e7bf0e2cf480 100644
--- a/core/modules/node/src/Plugin/views/row/Rss.php
+++ b/core/modules/node/src/Plugin/views/row/Rss.php
@@ -73,7 +73,7 @@ public function render($row) {
 
     $nid = $row->{$this->field_alias};
     if (!is_numeric($nid)) {
-      return;
+      return NULL;
     }
 
     $display_mode = $this->options['view_mode'];
@@ -85,7 +85,7 @@ public function render($row) {
     /** @var \Drupal\node\NodeInterface $node */
     $node = $this->nodes[$nid];
     if (empty($node)) {
-      return;
+      return NULL;
     }
 
     $node->rss_namespaces = [];
diff --git a/core/modules/search/search.module b/core/modules/search/search.module
index 92f4e78b7536..859c1f82ed52 100644
--- a/core/modules/search/search.module
+++ b/core/modules/search/search.module
@@ -37,6 +37,8 @@ function search_help($route_name, RouteMatchInterface $route_match) {
       $output .= '</dl>';
       return $output;
   }
+
+  return NULL;
 }
 
 /**
diff --git a/core/modules/serialization/serialization.module b/core/modules/serialization/serialization.module
index d191c2e0b90d..5d0336596caa 100644
--- a/core/modules/serialization/serialization.module
+++ b/core/modules/serialization/serialization.module
@@ -23,4 +23,6 @@ function serialization_help($route_name, RouteMatchInterface $route_match) {
       $output .= '<p>' . t('For more information, see the <a href=":doc_url">online documentation for the Serialization module</a>.', [':doc_url' => 'https://www.drupal.org/documentation/modules/serialization']) . '</p>';
       return $output;
   }
+
+  return NULL;
 }
diff --git a/core/modules/settings_tray/settings_tray.module b/core/modules/settings_tray/settings_tray.module
index ec276f3b38b6..c08ea58950c2 100644
--- a/core/modules/settings_tray/settings_tray.module
+++ b/core/modules/settings_tray/settings_tray.module
@@ -32,6 +32,8 @@ function settings_tray_help($route_name, RouteMatchInterface $route_match) {
       $output .= '</dl>';
       return ['#markup' => $output];
   }
+
+  return NULL;
 }
 
 /**
diff --git a/core/modules/shortcut/shortcut.api.php b/core/modules/shortcut/shortcut.api.php
index abdf357cd8af..c42e9ca88008 100644
--- a/core/modules/shortcut/shortcut.api.php
+++ b/core/modules/shortcut/shortcut.api.php
@@ -27,7 +27,7 @@
  * @param \Drupal\Core\Session\AccountInterface $account
  *   The user account whose default shortcut set is being requested.
  *
- * @return string
+ * @return null|string
  *   The name of the shortcut set that this module recommends for that user, if
  *   there is one.
  */
@@ -38,6 +38,8 @@ function hook_shortcut_default_set(\Drupal\Core\Session\AccountInterface $accoun
   if ($user_admin_roles) {
     return 'admin-shortcuts';
   }
+
+  return NULL;
 }
 
 /**
diff --git a/core/modules/shortcut/shortcut.module b/core/modules/shortcut/shortcut.module
index 9bc63b82298e..620e2acb1f8b 100644
--- a/core/modules/shortcut/shortcut.module
+++ b/core/modules/shortcut/shortcut.module
@@ -44,6 +44,8 @@ function shortcut_help($route_name, RouteMatchInterface $route_match) {
         return $output;
       }
   }
+
+  return NULL;
 }
 
 /**
diff --git a/core/modules/sqlite/sqlite.module b/core/modules/sqlite/sqlite.module
index 324b71bd6794..753e25c6c42e 100644
--- a/core/modules/sqlite/sqlite.module
+++ b/core/modules/sqlite/sqlite.module
@@ -19,4 +19,6 @@ function sqlite_help($route_name, RouteMatchInterface $route_match) {
       return $output;
 
   }
+
+  return NULL;
 }
diff --git a/core/modules/statistics/statistics.module b/core/modules/statistics/statistics.module
index 6f207b4dc4b2..26064dc5f258 100644
--- a/core/modules/statistics/statistics.module
+++ b/core/modules/statistics/statistics.module
@@ -32,6 +32,8 @@ function statistics_help($route_name, RouteMatchInterface $route_match) {
     case 'statistics.settings':
       return '<p>' . t('Settings for the statistical information that Drupal will keep about the site.') . '</p>';
   }
+
+  return NULL;
 }
 
 /**
@@ -110,6 +112,8 @@ function statistics_ranking() {
       ],
     ];
   }
+
+  return NULL;
 }
 
 /**
diff --git a/core/modules/syslog/syslog.module b/core/modules/syslog/syslog.module
index b13af5090367..684078b6d5b7 100644
--- a/core/modules/syslog/syslog.module
+++ b/core/modules/syslog/syslog.module
@@ -28,6 +28,8 @@ function syslog_help($route_name, RouteMatchInterface $route_match) {
       $output .= '</dl>';
       return $output;
   }
+
+  return NULL;
 }
 
 /**
diff --git a/core/modules/system/system.module b/core/modules/system/system.module
index 9a0926a9a923..485cb7ffb9b1 100644
--- a/core/modules/system/system.module
+++ b/core/modules/system/system.module
@@ -154,6 +154,8 @@ function system_help($route_name, RouteMatchInterface $route_match) {
     case 'system.status':
       return '<p>' . t("Here you can find a short overview of your site's parameters as well as any problems detected with your installation. It may be useful to copy and paste this information into support requests filed on Drupal.org's support forums and project issue queues. Before filing a support request, ensure that your web server meets the <a href=\":system-requirements\">system requirements.</a>", [':system-requirements' => 'https://www.drupal.org/docs/system-requirements']) . '</p>';
   }
+
+  return NULL;
 }
 
 /**
@@ -1393,6 +1395,8 @@ function system_file_download($uri) {
       ];
     }
   }
+
+  return NULL;
 }
 
 /**
diff --git a/core/modules/system/tests/modules/menu_test/src/Theme/TestThemeNegotiator.php b/core/modules/system/tests/modules/menu_test/src/Theme/TestThemeNegotiator.php
index 99203d68e0c3..b7c025c90e7a 100644
--- a/core/modules/system/tests/modules/menu_test/src/Theme/TestThemeNegotiator.php
+++ b/core/modules/system/tests/modules/menu_test/src/Theme/TestThemeNegotiator.php
@@ -29,17 +29,21 @@ public function determineActiveTheme(RouteMatchInterface $route_match) {
     if ($argument == 'use-admin-theme') {
       return \Drupal::config('system.theme')->get('admin');
     }
+
     // Test using a theme that exists, but may or may not be installed.
-    elseif ($argument == 'use-test-theme') {
+    if ($argument == 'use-test-theme') {
       return 'test_theme';
     }
+
     // Test using a theme that does not exist.
-    elseif ($argument == 'use-fake-theme') {
+    if ($argument == 'use-fake-theme') {
       return 'fake_theme';
     }
+
     // For any other value of the URL argument, do not return anything. This
     // allows us to test that returning nothing from a theme negotiation
     // causes the page to correctly fall back on using the main site theme.
+    return NULL;
   }
 
 }
diff --git a/core/modules/system/tests/modules/system_test/system_test.module b/core/modules/system/tests/modules/system_test/system_test.module
index e52b030abb1d..68b40cb719fb 100644
--- a/core/modules/system/tests/modules/system_test/system_test.module
+++ b/core/modules/system/tests/modules/system_test/system_test.module
@@ -19,6 +19,8 @@ function system_test_help($route_name, RouteMatchInterface $route_match) {
       $output .= '<p>' . t('This is a test help page for the system_test module for the purpose of testing if the "Help" link displays properly.') . '</p>';
       return $output;
   }
+
+  return NULL;
 }
 
 /**
diff --git a/core/modules/system/tests/src/Unit/Breadcrumbs/PathBasedBreadcrumbBuilderTest.php b/core/modules/system/tests/src/Unit/Breadcrumbs/PathBasedBreadcrumbBuilderTest.php
index 2f366bfef6af..a59a565bb998 100644
--- a/core/modules/system/tests/src/Unit/Breadcrumbs/PathBasedBreadcrumbBuilderTest.php
+++ b/core/modules/system/tests/src/Unit/Breadcrumbs/PathBasedBreadcrumbBuilderTest.php
@@ -197,6 +197,8 @@ public function testBuildWithTwoPathElements() {
             '_raw_variables' => new InputBag([]),
           ];
         }
+
+        return NULL;
       });
 
     $this->setupAccessManagerToAllow();
@@ -237,13 +239,16 @@ public function testBuildWithThreePathElements() {
             '_raw_variables' => new InputBag([]),
           ];
         }
-        elseif ($request->getPathInfo() == '/example') {
+
+        if ($request->getPathInfo() == '/example') {
           return [
             RouteObjectInterface::ROUTE_NAME => 'example',
             RouteObjectInterface::ROUTE_OBJECT => $route_2,
             '_raw_variables' => new InputBag([]),
           ];
         }
+
+        return NULL;
       });
 
     $this->accessManager->expects($this->any())
@@ -372,6 +377,8 @@ public function testBuildWithUserPath() {
             '_raw_variables' => new InputBag([]),
           ];
         }
+
+        return NULL;
       });
 
     $this->setupAccessManagerToAllow();
diff --git a/core/modules/taxonomy/src/Entity/Routing/VocabularyRouteProvider.php b/core/modules/taxonomy/src/Entity/Routing/VocabularyRouteProvider.php
index 9c144ef4e730..452ff165830f 100644
--- a/core/modules/taxonomy/src/Entity/Routing/VocabularyRouteProvider.php
+++ b/core/modules/taxonomy/src/Entity/Routing/VocabularyRouteProvider.php
@@ -34,6 +34,8 @@ protected function getCollectionRoute(EntityTypeInterface $entity_type) {
       $route->setRequirement('_permission', 'access taxonomy overview+administer taxonomy');
       return $route;
     }
+
+    return NULL;
   }
 
   /**
diff --git a/core/modules/taxonomy/src/Plugin/migrate/source/d7/TermTranslation.php b/core/modules/taxonomy/src/Plugin/migrate/source/d7/TermTranslation.php
index c58dba0731ee..7b23bbbe397d 100644
--- a/core/modules/taxonomy/src/Plugin/migrate/source/d7/TermTranslation.php
+++ b/core/modules/taxonomy/src/Plugin/migrate/source/d7/TermTranslation.php
@@ -50,6 +50,8 @@ public function prepareRow(Row $row) {
       return FALSE;
     }
     $row->setSourceProperty('language', $row->getSourceProperty('td_language'));
+
+    return TRUE;
   }
 
   /**
diff --git a/core/modules/taxonomy/src/Plugin/views/argument_default/Tid.php b/core/modules/taxonomy/src/Plugin/views/argument_default/Tid.php
index cf9bcd64a73e..d31b03c242be 100644
--- a/core/modules/taxonomy/src/Plugin/views/argument_default/Tid.php
+++ b/core/modules/taxonomy/src/Plugin/views/argument_default/Tid.php
@@ -194,6 +194,8 @@ public function getArgument() {
         }
       }
     }
+
+    return NULL;
   }
 
   /**
diff --git a/core/modules/taxonomy/taxonomy.module b/core/modules/taxonomy/taxonomy.module
index 5f011c6f9849..ba52c7b0ea01 100644
--- a/core/modules/taxonomy/taxonomy.module
+++ b/core/modules/taxonomy/taxonomy.module
@@ -44,6 +44,8 @@ function taxonomy_help($route_name, RouteMatchInterface $route_match) {
       $output = '<p>' . t('Taxonomy is for categorizing content. Terms are grouped into vocabularies. For example, a vocabulary called "Fruit" would contain the terms "Apple" and "Banana".') . '</p>';
       return $output;
   }
+
+  return NULL;
 }
 
 /**
diff --git a/core/modules/telephone/telephone.module b/core/modules/telephone/telephone.module
index 65a9b1c713c3..780e5c8f93f6 100644
--- a/core/modules/telephone/telephone.module
+++ b/core/modules/telephone/telephone.module
@@ -26,6 +26,8 @@ function telephone_help($route_name, RouteMatchInterface $route_match) {
       $output .= '</dl>';
       return $output;
   }
+
+  return NULL;
 }
 
 /**
diff --git a/core/modules/text/text.module b/core/modules/text/text.module
index c0a03c62f978..07b4e0812d4c 100644
--- a/core/modules/text/text.module
+++ b/core/modules/text/text.module
@@ -37,6 +37,8 @@ function text_help($route_name, RouteMatchInterface $route_match) {
       $output .= '</dl>';
       return $output;
   }
+
+  return NULL;
 }
 
 /**
diff --git a/core/modules/toolbar/toolbar.module b/core/modules/toolbar/toolbar.module
index e5ebb050393b..94d665ae12b4 100644
--- a/core/modules/toolbar/toolbar.module
+++ b/core/modules/toolbar/toolbar.module
@@ -32,6 +32,8 @@ function toolbar_help($route_name, RouteMatchInterface $route_match) {
       $output .= '</dl>';
       return $output;
   }
+
+  return NULL;
 }
 
 /**
diff --git a/core/modules/tour/src/TipPluginBase.php b/core/modules/tour/src/TipPluginBase.php
index bb24470c87ed..2fbb2ea460e9 100644
--- a/core/modules/tour/src/TipPluginBase.php
+++ b/core/modules/tour/src/TipPluginBase.php
@@ -53,9 +53,7 @@ public function getWeight() {
    * {@inheritdoc}
    */
   public function get($key) {
-    if (!empty($this->configuration[$key])) {
-      return $this->configuration[$key];
-    }
+    return $this->configuration[$key] ?? NULL;
   }
 
   /**
diff --git a/core/modules/tour/tour.module b/core/modules/tour/tour.module
index e6bbd2ae63a0..c800c9a7ee8d 100644
--- a/core/modules/tour/tour.module
+++ b/core/modules/tour/tour.module
@@ -26,6 +26,8 @@ function tour_help($route_name, RouteMatchInterface $route_match) {
       $output .= '</dl>';
       return $output;
   }
+
+  return NULL;
 }
 
 /**
diff --git a/core/modules/tracker/tracker.module b/core/modules/tracker/tracker.module
index 8dbc5ac2f274..d325b0468e08 100644
--- a/core/modules/tracker/tracker.module
+++ b/core/modules/tracker/tracker.module
@@ -29,6 +29,8 @@ function tracker_help($route_name, RouteMatchInterface $route_match) {
       $output .= '</dl>';
       return $output;
   }
+
+  return NULL;
 }
 
 /**
diff --git a/core/modules/update/update.manager.inc b/core/modules/update/update.manager.inc
index 0de8675ad11a..a00df5ba23d1 100644
--- a/core/modules/update/update.manager.inc
+++ b/core/modules/update/update.manager.inc
@@ -68,6 +68,8 @@ function update_manager_download_batch_finished($success, $results) {
     // but just in case, we have to tell them something.
     \Drupal::messenger()->addError(t('Fatal error trying to download.'));
   }
+
+  return NULL;
 }
 
 /**
diff --git a/core/modules/update/update.module b/core/modules/update/update.module
index ef6abc252312..52605de3cd21 100644
--- a/core/modules/update/update.module
+++ b/core/modules/update/update.module
@@ -53,6 +53,8 @@ function update_help($route_name, RouteMatchInterface $route_match) {
       return '<p>' . t('Regularly review <a href=":updates">available updates</a> and update as required to maintain a secure and current site. Always run the <a href=":update-php">update script</a> each time you update software.', [':update-php' => Url::fromRoute('system.db_update')->toString(), ':updates' => Url::fromRoute('update.status')->toString()]) . '</p>';
 
   }
+
+  return NULL;
 }
 
 /**
diff --git a/core/modules/user/src/Plugin/views/argument_default/User.php b/core/modules/user/src/Plugin/views/argument_default/User.php
index 3a4aa06c3c00..637ba9ce82d5 100644
--- a/core/modules/user/src/Plugin/views/argument_default/User.php
+++ b/core/modules/user/src/Plugin/views/argument_default/User.php
@@ -97,6 +97,8 @@ public function getArgument() {
         return $node->getOwnerId();
       }
     }
+
+    return NULL;
   }
 
   /**
diff --git a/core/modules/user/src/Plugin/views/field/UserData.php b/core/modules/user/src/Plugin/views/field/UserData.php
index 1a4bb82acdd5..6ef138156cd0 100644
--- a/core/modules/user/src/Plugin/views/field/UserData.php
+++ b/core/modules/user/src/Plugin/views/field/UserData.php
@@ -99,9 +99,9 @@ public function render(ResultRow $values) {
     $data = $this->userData->get($this->options['data_module'], $uid, $this->options['data_name']);
 
     // Don't sanitize if no value was found.
-    if (isset($data)) {
-      return $this->sanitizeValue($data);
-    }
+    return isset($data) ?
+      $this->sanitizeValue($data)
+      : NULL;
   }
 
 }
diff --git a/core/modules/user/user.install b/core/modules/user/user.install
index ae27e3bbf5ac..ea0278c057a9 100644
--- a/core/modules/user/user.install
+++ b/core/modules/user/user.install
@@ -135,4 +135,6 @@ function user_update_10000() {
       ['%role_list' => implode(', ', $cleaned_roles)]
     );
   }
+
+  return NULL;
 }
diff --git a/core/modules/user/user.module b/core/modules/user/user.module
index f22e525fbc2f..bf76754d547f 100644
--- a/core/modules/user/user.module
+++ b/core/modules/user/user.module
@@ -74,6 +74,8 @@ function user_help($route_name, RouteMatchInterface $route_match) {
     case 'entity.entity_view_display.user.default':
       return '<p>' . t('This form lets administrators configure how fields should be displayed when rendering a user profile page.') . '</p>';
   }
+
+  return NULL;
 }
 
 /**
@@ -213,9 +215,10 @@ function user_validate_name($name) {
   $data = \Drupal::typedDataManager()->create($definition);
   $data->setValue($name);
   $violations = $data->validate();
-  if (count($violations) > 0) {
-    return $violations[0]->getMessage();
-  }
+
+  return $violations->count() ?
+    $violations[0]->getMessage()
+    : NULL;
 }
 
 /**
diff --git a/core/modules/views/src/Plugin/views/area/TextCustom.php b/core/modules/views/src/Plugin/views/area/TextCustom.php
index 190210280ab9..1aa010125ba8 100644
--- a/core/modules/views/src/Plugin/views/area/TextCustom.php
+++ b/core/modules/views/src/Plugin/views/area/TextCustom.php
@@ -57,9 +57,9 @@ public function render($empty = FALSE) {
    * Render a text area with \Drupal\Component\Utility\Xss::filterAdmin().
    */
   public function renderTextarea($value) {
-    if ($value) {
-      return $this->sanitizeValue($this->tokenizeValue($value), 'xss_admin');
-    }
+    return $value ?
+      $this->sanitizeValue($this->tokenizeValue($value), 'xss_admin')
+      : NULL;
   }
 
 }
diff --git a/core/modules/views/src/Plugin/views/argument/ArgumentPluginBase.php b/core/modules/views/src/Plugin/views/argument/ArgumentPluginBase.php
index 3f08b596b2de..66fe6fa6eb93 100644
--- a/core/modules/views/src/Plugin/views/argument/ArgumentPluginBase.php
+++ b/core/modules/views/src/Plugin/views/argument/ArgumentPluginBase.php
@@ -588,15 +588,10 @@ protected function defaultActions($which = NULL) {
     }
 
     if ($which) {
-      if (!empty($defaults[$which])) {
-        return $defaults[$which];
-      }
-
-      return NULL;
-    }
-    else {
-      return $defaults;
+      return $defaults[$which] ?? NULL;
     }
+
+    return $defaults;
   }
 
   /**
diff --git a/core/modules/views/src/Plugin/views/query/Sql.php b/core/modules/views/src/Plugin/views/query/Sql.php
index fdf459aa390f..a47d50cbd19a 100644
--- a/core/modules/views/src/Plugin/views/query/Sql.php
+++ b/core/modules/views/src/Plugin/views/query/Sql.php
@@ -608,7 +608,7 @@ public function ensureTable($table, $relationship = NULL, JoinPluginBase $join =
     }
 
     if (!array_key_exists($relationship, $this->relationships)) {
-      return FALSE;
+      return NULL;
     }
 
     if ($table == $this->relationships[$relationship]['base']) {
@@ -663,6 +663,8 @@ public function ensureTable($table, $relationship = NULL, JoinPluginBase $join =
 
       return $this->queueTable($table, $relationship, $join);
     }
+
+    return NULL;
   }
 
   /**
@@ -806,6 +808,8 @@ public function getTableInfo($table) {
         return $this->tableQueue[$alias];
       }
     }
+
+    return NULL;
   }
 
   /**
diff --git a/core/modules/views/src/Plugin/views/style/StylePluginBase.php b/core/modules/views/src/Plugin/views/style/StylePluginBase.php
index f0c34b14d209..a48a5b239f53 100644
--- a/core/modules/views/src/Plugin/views/style/StylePluginBase.php
+++ b/core/modules/views/src/Plugin/views/style/StylePluginBase.php
@@ -196,12 +196,7 @@ public function usesFields() {
    * Used to ensure we don't fetch tokens when not needed for performance.
    */
   public function usesTokens() {
-    if ($this->usesRowClass()) {
-      $class = $this->options['row_class'];
-      if (str_contains($class, '{{')) {
-        return TRUE;
-      }
-    }
+    return $this->usesRowClass() && str_contains($this->options['row_class'], '{{');
   }
 
   /**
@@ -217,18 +212,21 @@ public function defaultFieldLabels() {
    * Return the token replaced row class for the specified row.
    */
   public function getRowClass($row_index) {
-    if ($this->usesRowClass()) {
-      $class = $this->options['row_class'];
-      if ($this->usesFields() && $this->view->field) {
-        $class = strip_tags($this->tokenizeValue($class, $row_index));
-      }
+    if (!$this->usesRowClass()) {
+      return '';
+    }
 
-      $classes = explode(' ', $class);
-      foreach ($classes as &$class) {
-        $class = Html::cleanCssIdentifier($class);
-      }
-      return implode(' ', $classes);
+    $class = $this->options['row_class'];
+    if ($this->usesFields() && $this->view->field) {
+      $class = strip_tags($this->tokenizeValue($class, $row_index));
+    }
+
+    $classes = explode(' ', $class);
+    foreach ($classes as &$class) {
+      $class = Html::cleanCssIdentifier($class);
     }
+
+    return implode(' ', $classes);
   }
 
   /**
@@ -786,6 +784,8 @@ public function getField($index, $field) {
     if (isset($this->rendered_fields[$index][$field])) {
       return $this->rendered_fields[$index][$field];
     }
+
+    return NULL;
   }
 
   /**
diff --git a/core/modules/views/src/ViewExecutable.php b/core/modules/views/src/ViewExecutable.php
index 599f840c9265..bcfdc65bc0f4 100644
--- a/core/modules/views/src/ViewExecutable.php
+++ b/core/modules/views/src/ViewExecutable.php
@@ -97,21 +97,21 @@ class ViewExecutable {
   /**
    * The current page. If the view uses pagination.
    *
-   * @var int
+   * @var null|int
    */
   protected $current_page = NULL;
 
   /**
    * The number of items per page.
    *
-   * @var int
+   * @var null|int
    */
   protected $items_per_page = NULL;
 
   /**
    * The pager offset.
    *
-   * @var int
+   * @var null|int
    */
   protected $offset = NULL;
 
@@ -204,7 +204,7 @@ class ViewExecutable {
   /**
    * The used pager plugin used by the current executed view.
    *
-   * @var \Drupal\views\Plugin\views\pager\PagerPluginBase
+   * @var null|\Drupal\views\Plugin\views\pager\PagerPluginBase
    */
   public $pager = NULL;
 
@@ -543,42 +543,34 @@ public function setCurrentPage($page) {
 
     // If the pager is already initialized, pass it through to the pager.
     if (!empty($this->pager)) {
-      return $this->pager->setCurrentPage($page);
+      $this->pager->setCurrentPage($page);
     }
   }
 
   /**
    * Gets the current page from the pager.
    *
-   * @return int
+   * @return null|int
    *   The current page.
    */
   public function getCurrentPage() {
     // If the pager is already initialized, pass it through to the pager.
-    if (!empty($this->pager)) {
-      return $this->pager->getCurrentPage();
-    }
-
-    if (isset($this->current_page)) {
-      return $this->current_page;
-    }
+    return $this->pager ?
+      $this->pager->getCurrentPage()
+      : $this->current_page;
   }
 
   /**
    * Gets the items per page from the pager.
    *
-   * @return int
+   * @return null|int
    *   The items per page.
    */
   public function getItemsPerPage() {
     // If the pager is already initialized, pass it through to the pager.
-    if (!empty($this->pager)) {
-      return $this->pager->getItemsPerPage();
-    }
-
-    if (isset($this->items_per_page)) {
-      return $this->items_per_page;
-    }
+    return $this->pager ?
+      $this->pager->getItemsPerPage()
+      : $this->items_per_page;
   }
 
   /**
@@ -604,18 +596,14 @@ public function setItemsPerPage($items_per_page) {
   /**
    * Gets the pager offset from the pager.
    *
-   * @return int
+   * @return null|int
    *   The pager offset.
    */
   public function getOffset() {
     // If the pager is already initialized, pass it through to the pager.
-    if (!empty($this->pager)) {
-      return $this->pager->getOffset();
-    }
-
-    if (isset($this->offset)) {
-      return $this->offset;
-    }
+    return $this->pager ?
+      $this->pager->getOffset()
+      : $this->offset;
   }
 
   /**
@@ -646,9 +634,7 @@ public function setOffset($offset) {
    *   TRUE if the view uses a pager, FALSE otherwise.
    */
   public function usePager() {
-    if (!empty($this->pager)) {
-      return $this->pager->usePager();
-    }
+    return $this->pager && $this->pager->usePager();
   }
 
   /**
diff --git a/core/modules/views/tests/modules/views_entity_test/views_entity_test.module b/core/modules/views/tests/modules/views_entity_test/views_entity_test.module
index 7d80e84c7857..c2bf1e2bc812 100644
--- a/core/modules/views/tests/modules/views_entity_test/views_entity_test.module
+++ b/core/modules/views/tests/modules/views_entity_test/views_entity_test.module
@@ -16,6 +16,7 @@
  * Implements hook_entity_bundle_field_info().
  */
 function views_entity_test_entity_base_field_info(EntityTypeInterface $entity_type) {
+  $definitions = [];
   if ($entity_type->id() == 'entity_test') {
     $definitions['test_text_access'] = BaseFieldDefinition::create('string')
       ->setLabel(t('Test access'))
@@ -25,8 +26,9 @@ function views_entity_test_entity_base_field_info(EntityTypeInterface $entity_ty
         'type' => 'string_textfield',
         'weight' => 10,
       ]);
-    return $definitions;
   }
+
+  return $definitions;
 }
 
 /**
diff --git a/core/modules/views/views.module b/core/modules/views/views.module
index fbedf1e4faff..7c39204c1c04 100644
--- a/core/modules/views/views.module
+++ b/core/modules/views/views.module
@@ -44,6 +44,8 @@ function views_help($route_name, RouteMatchInterface $route_match) {
       $output .= '</dl>';
       return $output;
   }
+
+  return NULL;
 }
 
 /**
diff --git a/core/modules/views_ui/views_ui.module b/core/modules/views_ui/views_ui.module
index 33dbb6b3c65f..61889e99e341 100644
--- a/core/modules/views_ui/views_ui.module
+++ b/core/modules/views_ui/views_ui.module
@@ -31,6 +31,8 @@ function views_ui_help($route_name, RouteMatchInterface $route_match) {
       $output .= '</dl>';
       return $output;
   }
+
+  return NULL;
 }
 
 /**
diff --git a/core/modules/workflows/workflows.module b/core/modules/workflows/workflows.module
index a22cadff97d2..a9de8ebb4495 100644
--- a/core/modules/workflows/workflows.module
+++ b/core/modules/workflows/workflows.module
@@ -24,4 +24,6 @@ function workflows_help($route_name, RouteMatchInterface $route_match) {
       $output .= '<p>' . t('The process of changing from one state to another. A transition can occur from multiple states, but only to one state.') . '</p>';
       return $output;
   }
+
+  return NULL;
 }
diff --git a/core/modules/workspaces/workspaces.module b/core/modules/workspaces/workspaces.module
index 05b2b2144ca7..e55d2b04a0e3 100644
--- a/core/modules/workspaces/workspaces.module
+++ b/core/modules/workspaces/workspaces.module
@@ -33,6 +33,8 @@ function workspaces_help($route_name, RouteMatchInterface $route_match) {
       $output .= '<p>' . t('The Workspaces module allows workspaces to be defined and switched between. Content is then assigned to the active workspace when created. For more information, see the <a href=":workspaces">online documentation for the Workspaces module</a>.', [':workspaces' => 'https://www.drupal.org/docs/8/core/modules/workspace/overview']) . '</p>';
       return $output;
   }
+
+  return NULL;
 }
 
 /**
diff --git a/core/phpstan-baseline.neon b/core/phpstan-baseline.neon
index 9ea58324f48c..bcfab165a5b4 100644
--- a/core/phpstan-baseline.neon
+++ b/core/phpstan-baseline.neon
@@ -170,11 +170,6 @@ parameters:
 			count: 1
 			path: lib/Drupal/Core/Access/AccessResult.php
 
-		-
-			message: "#^Method Drupal\\\\Core\\\\Access\\\\CsrfRequestHeaderAccessCheck\\:\\:applies\\(\\) should return bool but return statement is missing\\.$#"
-			count: 1
-			path: lib/Drupal/Core/Access/CsrfRequestHeaderAccessCheck.php
-
 		-
 			message: "#^Method Drupal\\\\Core\\\\Executable\\\\ExecutableInterface\\:\\:execute\\(\\) invoked with 1 parameter, 0 required\\.$#"
 			count: 1
@@ -190,11 +185,6 @@ parameters:
 			count: 1
 			path: lib/Drupal/Core/Action/ActionManager.php
 
-		-
-			message: "#^Method Drupal\\\\Core\\\\Archiver\\\\ArchiverManager\\:\\:getInstance\\(\\) should return object\\|false but return statement is missing\\.$#"
-			count: 1
-			path: lib/Drupal/Core/Archiver/ArchiverManager.php
-
 		-
 			message: "#^Variable \\$group_keys might not be defined\\.$#"
 			count: 2
@@ -265,11 +255,6 @@ parameters:
 			count: 1
 			path: lib/Drupal/Core/Config/ExtensionInstallStorage.php
 
-		-
-			message: "#^Method Drupal\\\\Core\\\\Config\\\\TypedConfigManager\\:\\:replaceVariable\\(\\) should return string but return statement is missing\\.$#"
-			count: 1
-			path: lib/Drupal/Core/Config/TypedConfigManager.php
-
 		-
 			message: "#^Variable \\$statement might not be defined\\.$#"
 			count: 1
@@ -335,11 +320,6 @@ parameters:
 			count: 1
 			path: lib/Drupal/Core/Entity/ContentEntityStorageBase.php
 
-		-
-			message: "#^Method Drupal\\\\Core\\\\Entity\\\\Controller\\\\EntityController\\:\\:deleteTitle\\(\\) should return string but return statement is missing\\.$#"
-			count: 1
-			path: lib/Drupal/Core/Entity/Controller/EntityController.php
-
 		-
 			message: "#^Variable \\$candidate_ids might not be defined\\.$#"
 			count: 2
@@ -420,16 +400,6 @@ parameters:
 			count: 2
 			path: lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php
 
-		-
-			message: "#^Method Drupal\\\\Core\\\\Entity\\\\Sql\\\\SqlContentEntityStorageSchema\\:\\:processDataTable\\(\\) should return array but return statement is missing\\.$#"
-			count: 1
-			path: lib/Drupal/Core/Entity/Sql/SqlContentEntityStorageSchema.php
-
-		-
-			message: "#^Method Drupal\\\\Core\\\\Entity\\\\Sql\\\\SqlContentEntityStorageSchema\\:\\:processRevisionDataTable\\(\\) should return array but return statement is missing\\.$#"
-			count: 1
-			path: lib/Drupal/Core/Entity/Sql/SqlContentEntityStorageSchema.php
-
 		-
 			message: "#^Variable \\$initial_storage_value in empty\\(\\) always exists and is not falsy\\.$#"
 			count: 1
@@ -460,11 +430,6 @@ parameters:
 			count: 1
 			path: lib/Drupal/Core/Field/FieldItemBase.php
 
-		-
-			message: "#^Method Drupal\\\\Core\\\\Field\\\\FieldItemList\\:\\:defaultValuesForm\\(\\) should return array but return statement is missing\\.$#"
-			count: 1
-			path: lib/Drupal/Core/Field/FieldItemList.php
-
 		-
 			message: "#^Variable \\$values might not be defined\\.$#"
 			count: 1
@@ -495,11 +460,6 @@ parameters:
 			count: 1
 			path: lib/Drupal/Core/Field/Plugin/Field/FieldType/CreatedItem.php
 
-		-
-			message: "#^Method Drupal\\\\Core\\\\Field\\\\Plugin\\\\Field\\\\FieldType\\\\EntityReferenceItem\\:\\:generateSampleValue\\(\\) should return array but return statement is missing\\.$#"
-			count: 1
-			path: lib/Drupal/Core/Field/Plugin/Field/FieldType/EntityReferenceItem.php
-
 		-
 			message: "#^Access to an undefined property Drupal\\\\Core\\\\Field\\\\Plugin\\\\Field\\\\FieldType\\\\NumericItemBase\\:\\:\\$value\\.$#"
 			count: 1
@@ -515,11 +475,6 @@ parameters:
 			count: 3
 			path: lib/Drupal/Core/FileTransfer/FileTransfer.php
 
-		-
-			message: "#^Method Drupal\\\\Core\\\\FileTransfer\\\\FileTransfer\\:\\:__get\\(\\) should return bool\\|string but return statement is missing\\.$#"
-			count: 1
-			path: lib/Drupal/Core/FileTransfer/FileTransfer.php
-
 		-
 			message: "#^Access to an undefined property Drupal\\\\Core\\\\FileTransfer\\\\SSH\\:\\:\\$connection\\.$#"
 			count: 9
@@ -595,11 +550,6 @@ parameters:
 			count: 1
 			path: lib/Drupal/Core/Menu/Form/MenuLinkDefaultForm.php
 
-		-
-			message: "#^Method Drupal\\\\Core\\\\Menu\\\\MenuLinkManager\\:\\:getInstance\\(\\) should return object\\|false but return statement is missing\\.$#"
-			count: 1
-			path: lib/Drupal/Core/Menu/MenuLinkManager.php
-
 		-
 			message: "#^Method Drupal\\\\Core\\\\Menu\\\\MenuLinkManager\\:\\:menuNameInUse\\(\\) should return bool but return statement is missing\\.$#"
 			count: 1
@@ -670,11 +620,6 @@ parameters:
 			count: 3
 			path: lib/Drupal/Core/Site/SettingsEditor.php
 
-		-
-			message: "#^Method Drupal\\\\Core\\\\Template\\\\AttributeValueBase\\:\\:render\\(\\) should return string but return statement is missing\\.$#"
-			count: 1
-			path: lib/Drupal/Core/Template/AttributeValueBase.php
-
 		-
 			message: "#^Constructor of class Drupal\\\\Core\\\\Template\\\\TwigEnvironment has an unused parameter \\$root\\.$#"
 			count: 1
@@ -690,11 +635,6 @@ parameters:
 			count: 1
 			path: lib/Drupal/Core/Test/TestRunnerKernel.php
 
-		-
-			message: "#^Method Drupal\\\\Core\\\\Theme\\\\ThemeInitialization\\:\\:resolveStyleSheetPlaceholders\\(\\) should return string but return statement is missing\\.$#"
-			count: 1
-			path: lib/Drupal/Core/Theme/ThemeInitialization.php
-
 		-
 			message: "#^Variable \\$candidate in isset\\(\\) is never defined\\.$#"
 			count: 1
@@ -805,16 +745,6 @@ parameters:
 			count: 1
 			path: modules/book/src/BookExport.php
 
-		-
-			message: "#^Method Drupal\\\\book\\\\BookOutline\\:\\:nextLink\\(\\) should return array but return statement is missing\\.$#"
-			count: 1
-			path: modules/book/src/BookOutline.php
-
-		-
-			message: "#^Method Drupal\\\\book\\\\BookOutline\\:\\:prevLink\\(\\) should return array but return statement is missing\\.$#"
-			count: 1
-			path: modules/book/src/BookOutline.php
-
 		-
 			message: "#^Method Drupal\\\\book\\\\Form\\\\BookOutlineForm\\:\\:save\\(\\) should return int but return statement is missing\\.$#"
 			count: 1
@@ -875,11 +805,6 @@ parameters:
 			count: 1
 			path: modules/comment/src/Plugin/migrate/destination/EntityComment.php
 
-		-
-			message: "#^Method Drupal\\\\comment\\\\Plugin\\\\views\\\\field\\\\NodeNewComments\\:\\:render\\(\\) should return Drupal\\\\Component\\\\Render\\\\MarkupInterface\\|string but return statement is missing\\.$#"
-			count: 1
-			path: modules/comment/src/Plugin/views/field/NodeNewComments.php
-
 		-
 			message: "#^Variable \\$comment in empty\\(\\) always exists and is not falsy\\.$#"
 			count: 1
@@ -965,11 +890,6 @@ parameters:
 			count: 1
 			path: modules/content_moderation/src/ModerationInformation.php
 
-		-
-			message: "#^Method Drupal\\\\content_moderation\\\\ModerationInformation\\:\\:getDefaultRevisionId\\(\\) should return int but return statement is missing\\.$#"
-			count: 1
-			path: modules/content_moderation/src/ModerationInformation.php
-
 		-
 			message: "#^Variable \\$checkbox_id might not be defined\\.$#"
 			count: 1
@@ -1010,11 +930,6 @@ parameters:
 			count: 1
 			path: modules/contextual/tests/src/FunctionalJavascript/EditModeTest.php
 
-		-
-			message: "#^Method Drupal\\\\datetime\\\\Plugin\\\\Field\\\\FieldType\\\\DateTimeFieldItemList\\:\\:defaultValuesForm\\(\\) should return array but return statement is missing\\.$#"
-			count: 1
-			path: modules/datetime/src/Plugin/Field/FieldType/DateTimeFieldItemList.php
-
 		-
 			message: "#^Access to an undefined property Drupal\\\\datetime\\\\Plugin\\\\Field\\\\FieldType\\\\DateTimeItem\\:\\:\\$date\\.$#"
 			count: 1
@@ -1045,11 +960,6 @@ parameters:
 			count: 1
 			path: modules/datetime/tests/src/Kernel/Views/FilterDateTimeTest.php
 
-		-
-			message: "#^Method Drupal\\\\datetime_range\\\\Plugin\\\\Field\\\\FieldType\\\\DateRangeFieldItemList\\:\\:defaultValuesForm\\(\\) should return array but return statement is missing\\.$#"
-			count: 1
-			path: modules/datetime_range/src/Plugin/Field/FieldType/DateRangeFieldItemList.php
-
 		-
 			message: "#^Access to an undefined property Drupal\\\\datetime_range\\\\Plugin\\\\Field\\\\FieldType\\\\DateRangeItem\\:\\:\\$end_date\\.$#"
 			count: 1
@@ -1115,11 +1025,6 @@ parameters:
 			count: 1
 			path: modules/field_ui/src/Access/ViewModeAccessCheck.php
 
-		-
-			message: "#^Method Drupal\\\\field_ui\\\\FieldUI\\:\\:getOverviewRouteInfo\\(\\) should return Drupal\\\\Core\\\\Url but return statement is missing\\.$#"
-			count: 1
-			path: modules/field_ui/src/FieldUI.php
-
 		-
 			message: "#^Variable \\$updated_columns might not be defined\\.$#"
 			count: 1
@@ -1290,11 +1195,6 @@ parameters:
 			count: 1
 			path: modules/jsonapi/src/Context/FieldResolver.php
 
-		-
-			message: "#^Method Drupal\\\\jsonapi\\\\JsonApiResource\\\\ResourceIdentifier\\:\\:getDataReferencePropertyName\\(\\) should return string but return statement is missing\\.$#"
-			count: 1
-			path: modules/jsonapi/src/JsonApiResource/ResourceIdentifier.php
-
 		-
 			message: "#^Variable \\$entity in isset\\(\\) always exists and is not nullable\\.$#"
 			count: 1
@@ -1385,11 +1285,6 @@ parameters:
 			count: 1
 			path: modules/locale/src/Form/TranslationStatusForm.php
 
-		-
-			message: "#^Method Drupal\\\\locale\\\\LocaleDefaultConfigStorage\\:\\:read\\(\\) should return array but return statement is missing\\.$#"
-			count: 1
-			path: modules/locale/src/LocaleDefaultConfigStorage.php
-
 		-
 			message: "#^Method Drupal\\\\locale\\\\LocaleProjectStorage\\:\\:deleteAll\\(\\) should return array but return statement is missing\\.$#"
 			count: 1
@@ -1400,21 +1295,6 @@ parameters:
 			count: 1
 			path: modules/locale/src/LocaleProjectStorage.php
 
-		-
-			message: "#^Method Drupal\\\\locale\\\\PluralFormula\\:\\:loadFormulae\\(\\) should return array but return statement is missing\\.$#"
-			count: 1
-			path: modules/locale/src/PluralFormula.php
-
-		-
-			message: "#^Method Drupal\\\\locale\\\\PoDatabaseReader\\:\\:readItem\\(\\) should return Drupal\\\\Component\\\\Gettext\\\\PoItem but return statement is missing\\.$#"
-			count: 1
-			path: modules/locale/src/PoDatabaseReader.php
-
-		-
-			message: "#^Method Drupal\\\\locale\\\\PoDatabaseWriter\\:\\:importString\\(\\) should return int but return statement is missing\\.$#"
-			count: 1
-			path: modules/locale/src/PoDatabaseWriter.php
-
 		-
 			message: "#^Variable \\$plural in isset\\(\\) always exists and is not nullable\\.$#"
 			count: 1
@@ -1750,31 +1630,11 @@ parameters:
 			count: 1
 			path: modules/node/tests/src/Kernel/Migrate/d7/MigrateNodeTest.php
 
-		-
-			message: "#^Method Drupal\\\\options\\\\Plugin\\\\Field\\\\FieldType\\\\ListFloatItem\\:\\:validateAllowedValue\\(\\) should return string but return statement is missing\\.$#"
-			count: 1
-			path: modules/options/src/Plugin/Field/FieldType/ListFloatItem.php
-
-		-
-			message: "#^Method Drupal\\\\options\\\\Plugin\\\\Field\\\\FieldType\\\\ListIntegerItem\\:\\:validateAllowedValue\\(\\) should return string but return statement is missing\\.$#"
-			count: 1
-			path: modules/options/src/Plugin/Field/FieldType/ListIntegerItem.php
-
 		-
 			message: "#^Access to an undefined property Drupal\\\\options\\\\Plugin\\\\Field\\\\FieldType\\\\ListItemBase\\:\\:\\$value\\.$#"
 			count: 1
 			path: modules/options/src/Plugin/Field/FieldType/ListItemBase.php
 
-		-
-			message: "#^Method Drupal\\\\options\\\\Plugin\\\\Field\\\\FieldType\\\\ListItemBase\\:\\:validateAllowedValue\\(\\) should return string but return statement is missing\\.$#"
-			count: 1
-			path: modules/options/src/Plugin/Field/FieldType/ListItemBase.php
-
-		-
-			message: "#^Method Drupal\\\\options\\\\Plugin\\\\Field\\\\FieldType\\\\ListStringItem\\:\\:validateAllowedValue\\(\\) should return string but return statement is missing\\.$#"
-			count: 1
-			path: modules/options/src/Plugin/Field/FieldType/ListStringItem.php
-
 		-
 			message: "#^Method Drupal\\\\path\\\\PathAliasForm\\:\\:save\\(\\) should return int but return statement is missing\\.$#"
 			count: 1
@@ -1930,11 +1790,6 @@ parameters:
 			count: 1
 			path: modules/system/src/Form/DateFormatFormBase.php
 
-		-
-			message: "#^Method Drupal\\\\system\\\\Form\\\\ModulesListNonStableConfirmForm\\:\\:getQuestion\\(\\) should return Drupal\\\\Core\\\\StringTranslation\\\\TranslatableMarkup but return statement is missing\\.$#"
-			count: 1
-			path: modules/system/src/Form/ModulesListNonStableConfirmForm.php
-
 		-
 			message: "#^Variable \\$default_theme in isset\\(\\) always exists and is not nullable\\.$#"
 			count: 1
@@ -2020,11 +1875,6 @@ parameters:
 			count: 1
 			path: modules/taxonomy/src/Form/OverviewTerms.php
 
-		-
-			message: "#^Method Drupal\\\\taxonomy\\\\Plugin\\\\migrate\\\\source\\\\d7\\\\TermTranslation\\:\\:prepareRow\\(\\) should return bool but return statement is missing\\.$#"
-			count: 1
-			path: modules/taxonomy/src/Plugin/migrate/source/d7/TermTranslation.php
-
 		-
 			message: "#^Variable \\$inner_count might not be defined\\.$#"
 			count: 1
@@ -2145,11 +1995,6 @@ parameters:
 			count: 1
 			path: modules/user/src/Plugin/Validation/Constraint/UserMailRequiredValidator.php
 
-		-
-			message: "#^Method Drupal\\\\user\\\\Plugin\\\\views\\\\field\\\\UserData\\:\\:render\\(\\) should return Drupal\\\\Component\\\\Render\\\\MarkupInterface\\|string but return statement is missing\\.$#"
-			count: 1
-			path: modules/user/src/Plugin/views/field/UserData.php
-
 		-
 			message: "#^Method Drupal\\\\user\\\\ProfileForm\\:\\:save\\(\\) should return int but return statement is missing\\.$#"
 			count: 1
@@ -2240,11 +2085,6 @@ parameters:
 			count: 1
 			path: modules/views/src/Plugin/views/HandlerBase.php
 
-		-
-			message: "#^Method Drupal\\\\views\\\\Plugin\\\\views\\\\HandlerBase\\:\\:getTableJoin\\(\\) should return Drupal\\\\views\\\\Plugin\\\\views\\\\join\\\\JoinPluginBase but return statement is missing\\.$#"
-			count: 1
-			path: modules/views/src/Plugin/views/HandlerBase.php
-
 		-
 			message: "#^Variable \\$group_types might not be defined\\.$#"
 			count: 1
@@ -2255,11 +2095,6 @@ parameters:
 			count: 1
 			path: modules/views/src/Plugin/views/area/Broken.php
 
-		-
-			message: "#^Method Drupal\\\\views\\\\Plugin\\\\views\\\\area\\\\HTTPStatusCode\\:\\:render\\(\\) should return array but return statement is missing\\.$#"
-			count: 1
-			path: modules/views/src/Plugin/views/area/HTTPStatusCode.php
-
 		-
 			message: "#^Variable \\$options_name might not be defined\\.$#"
 			count: 1
@@ -2335,11 +2170,6 @@ parameters:
 			count: 2
 			path: modules/views/src/Plugin/views/field/Date.php
 
-		-
-			message: "#^Method Drupal\\\\views\\\\Plugin\\\\views\\\\field\\\\Date\\:\\:render\\(\\) should return Drupal\\\\Component\\\\Render\\\\MarkupInterface\\|string but return statement is missing\\.$#"
-			count: 1
-			path: modules/views/src/Plugin/views/field/Date.php
-
 		-
 			message: "#^Variable \\$custom_format might not be defined\\.$#"
 			count: 9
@@ -2350,11 +2180,6 @@ parameters:
 			count: 1
 			path: modules/views/src/Plugin/views/field/EntityField.php
 
-		-
-			message: "#^Method Drupal\\\\views\\\\Plugin\\\\views\\\\field\\\\EntityField\\:\\:renderItems\\(\\) should return string but return statement is missing\\.$#"
-			count: 1
-			path: modules/views/src/Plugin/views/field/EntityField.php
-
 		-
 			message: "#^Variable \\$field_item_list in isset\\(\\) always exists and is not nullable\\.$#"
 			count: 1
@@ -2645,11 +2470,6 @@ parameters:
 			count: 1
 			path: modules/workflows/src/Form/WorkflowTransitionEditForm.php
 
-		-
-			message: "#^Method Drupal\\\\workspaces\\\\EntityTypeInfo\\:\\:entityBaseFieldInfo\\(\\) should return array\\<Drupal\\\\Core\\\\Field\\\\FieldDefinitionInterface\\> but return statement is missing\\.$#"
-			count: 1
-			path: modules/workspaces/src/EntityTypeInfo.php
-
 		-
 			message: "#^Method Drupal\\\\workspaces\\\\Form\\\\WorkspaceForm\\:\\:save\\(\\) should return int but return statement is missing\\.$#"
 			count: 1
diff --git a/core/tests/Drupal/FunctionalTests/Update/UpdatePathTestBase.php b/core/tests/Drupal/FunctionalTests/Update/UpdatePathTestBase.php
index ed5e1425a3df..90b3ccbf729a 100644
--- a/core/tests/Drupal/FunctionalTests/Update/UpdatePathTestBase.php
+++ b/core/tests/Drupal/FunctionalTests/Update/UpdatePathTestBase.php
@@ -265,8 +265,8 @@ protected function prepareSettings() {
   protected function runUpdates() {
     if (!$this->zlibInstalled) {
       $this->fail('Missing zlib requirement for update tests.');
-      return FALSE;
     }
+
     $this->doRunUpdates($this->updateUrl);
   }
 
diff --git a/core/tests/Drupal/KernelTests/Core/Database/QueryTest.php b/core/tests/Drupal/KernelTests/Core/Database/QueryTest.php
index d5b6c9e865de..d621e995d04a 100644
--- a/core/tests/Drupal/KernelTests/Core/Database/QueryTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Database/QueryTest.php
@@ -81,6 +81,8 @@ public function testConditionOperatorArgumentsSQLInjection() {
       if ($previous_error_handler) {
         return $previous_error_handler($severity, $message, $filename, $lineno);
       }
+
+      return NULL;
     });
     try {
       $result = $this->connection->select('test', 't')
diff --git a/core/tests/Drupal/Tests/Core/Asset/LibraryDiscoveryTest.php b/core/tests/Drupal/Tests/Core/Asset/LibraryDiscoveryTest.php
index b53d6a72b928..203535d47436 100644
--- a/core/tests/Drupal/Tests/Core/Asset/LibraryDiscoveryTest.php
+++ b/core/tests/Drupal/Tests/Core/Asset/LibraryDiscoveryTest.php
@@ -108,9 +108,10 @@ public function testAssetLibraryDeprecation() {
       if ($severity === E_USER_DEPRECATED) {
         throw new \ErrorException($message, 0, $severity, $file, $line);
       }
-      if ($previous_error_handler) {
-        return $previous_error_handler($severity, $message, $file, $line);
-      }
+
+      return $previous_error_handler ?
+        $previous_error_handler($severity, $message, $file, $line)
+        : NULL;
     });
 
     try {
diff --git a/core/tests/Drupal/Tests/Core/Command/QuickStartTest.php b/core/tests/Drupal/Tests/Core/Command/QuickStartTest.php
index bcce6a91a4f4..09a6343cee5f 100644
--- a/core/tests/Drupal/Tests/Core/Command/QuickStartTest.php
+++ b/core/tests/Drupal/Tests/Core/Command/QuickStartTest.php
@@ -110,6 +110,8 @@ public function testQuickStartCommand() {
         $port = $match[1];
         return TRUE;
       }
+
+      return FALSE;
     });
     // The progress bar uses STDERR to write messages.
     $this->assertStringContainsString('Congratulations, you installed Drupal!', $process->getErrorOutput());
@@ -175,6 +177,8 @@ public function testQuickStartInstallAndServerCommands() {
         $port = $match[1];
         return TRUE;
       }
+
+      return FALSE;
     });
     $this->assertEquals('', $server_process->getErrorOutput());
     $this->assertStringContainsString("127.0.0.1:$port/user/reset/1/", $server_process->getOutput());
diff --git a/core/tests/Drupal/Tests/Core/Entity/EntityFieldManagerTest.php b/core/tests/Drupal/Tests/Core/Entity/EntityFieldManagerTest.php
index 933c678d4314..98a6192cba47 100644
--- a/core/tests/Drupal/Tests/Core/Entity/EntityFieldManagerTest.php
+++ b/core/tests/Drupal/Tests/Core/Entity/EntityFieldManagerTest.php
@@ -212,9 +212,7 @@ protected function setUpEntityTypeDefinitions($definitions = []) {
       });
     $this->entityTypeManager->getDefinition(Argument::type('string'), FALSE)
       ->will(function ($args) use ($definitions) {
-        if (isset($definitions[$args[0]])) {
-          return $definitions[$args[0]];
-        }
+        return $definitions[$args[0]] ?? NULL;
       });
     $this->entityTypeManager->getDefinitions()->willReturn($definitions);
 
diff --git a/core/tests/Drupal/Tests/Core/Utility/LinkGeneratorTest.php b/core/tests/Drupal/Tests/Core/Utility/LinkGeneratorTest.php
index 16bda9820a31..56b914baba0c 100644
--- a/core/tests/Drupal/Tests/Core/Utility/LinkGeneratorTest.php
+++ b/core/tests/Drupal/Tests/Core/Utility/LinkGeneratorTest.php
@@ -473,6 +473,8 @@ public function testGenerateActive() {
               return (new GeneratedUrl())->setGeneratedUrl('/test-route-4/1');
             }
         }
+
+        return NULL;
       });
 
     $this->urlGenerator->expects($this->exactly(4))
-- 
GitLab