diff --git a/core/.phpstan-baseline.php b/core/.phpstan-baseline.php
index 7cfae86c332afd95ac2575c49bc87d76300f7df7..5468cfee172c50231745ff5fed6cb1ed2845b09e 100644
--- a/core/.phpstan-baseline.php
+++ b/core/.phpstan-baseline.php
@@ -13447,12 +13447,6 @@
 	'count' => 1,
 	'path' => __DIR__ . '/modules/comment/src/Hook/CommentHooks.php',
 ];
-$ignoreErrors[] = [
-	'message' => '#^Method Drupal\\\\comment\\\\Hook\\\\CommentHooks\\:\\:nodeUpdateIndex\\(\\) has no return type specified\\.$#',
-	'identifier' => 'missingType.return',
-	'count' => 1,
-	'path' => __DIR__ . '/modules/comment/src/Hook/CommentHooks.php',
-];
 $ignoreErrors[] = [
 	'message' => '#^Method Drupal\\\\comment\\\\Plugin\\\\EntityReferenceSelection\\\\CommentSelection\\:\\:entityQueryAlter\\(\\) has no return type specified\\.$#',
 	'identifier' => 'missingType.return',
@@ -16609,12 +16603,6 @@
 	'count' => 1,
 	'path' => __DIR__ . '/modules/content_translation/tests/src/Unit/Menu/ContentTranslationLocalTasksTest.php',
 ];
-$ignoreErrors[] = [
-	'message' => '#^Function contextual_preprocess\\(\\) has no return type specified\\.$#',
-	'identifier' => 'missingType.return',
-	'count' => 1,
-	'path' => __DIR__ . '/modules/contextual/contextual.module',
-];
 $ignoreErrors[] = [
 	'message' => '#^Method Drupal\\\\contextual\\\\ContextualController\\:\\:create\\(\\) has no return type specified\\.$#',
 	'identifier' => 'missingType.return',
@@ -31609,12 +31597,6 @@
 	'count' => 1,
 	'path' => __DIR__ . '/modules/search/tests/modules/search_extra_type/src/Plugin/Search/SearchExtraTypeSearch.php',
 ];
-$ignoreErrors[] = [
-	'message' => '#^Method Drupal\\\\search_langcode_test\\\\Hook\\\\SearchLangcodeTestHooks\\:\\:searchPreprocess\\(\\) has no return type specified\\.$#',
-	'identifier' => 'missingType.return',
-	'count' => 1,
-	'path' => __DIR__ . '/modules/search/tests/modules/search_langcode_test/src/Hook/SearchLangcodeTestHooks.php',
-];
 $ignoreErrors[] = [
 	'message' => '#^Method Drupal\\\\Tests\\\\search\\\\Functional\\\\Rest\\\\SearchPageJsonAnonTest\\:\\:assertAuthenticationEdgeCases\\(\\) has no return type specified\\.$#',
 	'identifier' => 'missingType.return',
@@ -33877,12 +33859,6 @@
 	'count' => 1,
 	'path' => __DIR__ . '/modules/system/tests/modules/default_format_test/src/DefaultFormatTestController.php',
 ];
-$ignoreErrors[] = [
-	'message' => '#^Function deprecation_test_deprecated_hook\\(\\) has no return type specified\\.$#',
-	'identifier' => 'missingType.return',
-	'count' => 1,
-	'path' => __DIR__ . '/modules/system/tests/modules/deprecation_test/deprecation_test.module',
-];
 $ignoreErrors[] = [
 	'message' => '#^Call to deprecated function deprecation_test_function\\(\\)\\:
 in drupal\\:8\\.4\\.0 and is removed from drupal\\:9\\.0\\.0\\. This is
@@ -35667,36 +35643,12 @@
 	'count' => 1,
 	'path' => __DIR__ . '/modules/system/tests/modules/module_autoload_test/src/SomeClass.php',
 ];
-$ignoreErrors[] = [
-	'message' => '#^Function module_test_test_hook\\(\\) has no return type specified\\.$#',
-	'identifier' => 'missingType.return',
-	'count' => 1,
-	'path' => __DIR__ . '/modules/system/tests/modules/module_test/module_test.file.inc',
-];
-$ignoreErrors[] = [
-	'message' => '#^Function module_test_altered_test_hook\\(\\) has no return type specified\\.$#',
-	'identifier' => 'missingType.return',
-	'count' => 1,
-	'path' => __DIR__ . '/modules/system/tests/modules/module_test/module_test.implementations.inc',
-];
 $ignoreErrors[] = [
 	'message' => '#^Function module_test_load\\(\\) has no return type specified\\.$#',
 	'identifier' => 'missingType.return',
 	'count' => 1,
 	'path' => __DIR__ . '/modules/system/tests/modules/module_test/module_test.module',
 ];
-$ignoreErrors[] = [
-	'message' => '#^Function module_test_modules_installed\\(\\) has no return type specified\\.$#',
-	'identifier' => 'missingType.return',
-	'count' => 1,
-	'path' => __DIR__ . '/modules/system/tests/modules/module_test/module_test.module',
-];
-$ignoreErrors[] = [
-	'message' => '#^Function module_test_modules_uninstalled\\(\\) has no return type specified\\.$#',
-	'identifier' => 'missingType.return',
-	'count' => 1,
-	'path' => __DIR__ . '/modules/system/tests/modules/module_test/module_test.module',
-];
 $ignoreErrors[] = [
 	'message' => '#^Function module_test_post_update_test\\(\\) has no return type specified\\.$#',
 	'identifier' => 'missingType.return',
@@ -38409,30 +38361,6 @@
 	'count' => 1,
 	'path' => __DIR__ . '/modules/system/tests/src/Unit/Routing/AdminRouteSubscriberTest.php',
 ];
-$ignoreErrors[] = [
-	'message' => '#^Function nyan_cat_extension\\(\\) has no return type specified\\.$#',
-	'identifier' => 'missingType.return',
-	'count' => 1,
-	'path' => __DIR__ . '/modules/system/tests/themes/engines/nyan_cat/nyan_cat.engine',
-];
-$ignoreErrors[] = [
-	'message' => '#^Function nyan_cat_render_template\\(\\) has no return type specified\\.$#',
-	'identifier' => 'missingType.return',
-	'count' => 1,
-	'path' => __DIR__ . '/modules/system/tests/themes/engines/nyan_cat/nyan_cat.engine',
-];
-$ignoreErrors[] = [
-	'message' => '#^Function test_subtheme_views_post_render\\(\\) has no return type specified\\.$#',
-	'identifier' => 'missingType.return',
-	'count' => 1,
-	'path' => __DIR__ . '/modules/system/tests/themes/test_subtheme/test_subtheme.theme',
-];
-$ignoreErrors[] = [
-	'message' => '#^Function test_subtheme_views_pre_render\\(\\) has no return type specified\\.$#',
-	'identifier' => 'missingType.return',
-	'count' => 1,
-	'path' => __DIR__ . '/modules/system/tests/themes/test_subtheme/test_subtheme.theme',
-];
 $ignoreErrors[] = [
 	'message' => '#^Function test_theme_depending_on_modules_post_update_module_install\\(\\) has no return type specified\\.$#',
 	'identifier' => 'missingType.return',
@@ -58344,12 +58272,6 @@
 	'count' => 1,
 	'path' => __DIR__ . '/themes/claro/claro.theme',
 ];
-$ignoreErrors[] = [
-	'message' => '#^Function claro_views_pre_render\\(\\) has no return type specified\\.$#',
-	'identifier' => 'missingType.return',
-	'count' => 1,
-	'path' => __DIR__ . '/themes/claro/claro.theme',
-];
 $ignoreErrors[] = [
 	'message' => '#^Method Drupal\\\\claro\\\\ClaroPreRender\\:\\:managedFile\\(\\) has no return type specified\\.$#',
 	'identifier' => 'missingType.return',
@@ -58374,18 +58296,6 @@
 	'count' => 1,
 	'path' => __DIR__ . '/themes/claro/src/ClaroPreRender.php',
 ];
-$ignoreErrors[] = [
-	'message' => '#^Function twig_extension\\(\\) has no return type specified\\.$#',
-	'identifier' => 'missingType.return',
-	'count' => 1,
-	'path' => __DIR__ . '/themes/engines/twig/twig.engine',
-];
-$ignoreErrors[] = [
-	'message' => '#^Function twig_render_template\\(\\) has no return type specified\\.$#',
-	'identifier' => 'missingType.return',
-	'count' => 1,
-	'path' => __DIR__ . '/themes/engines/twig/twig.engine',
-];
 $ignoreErrors[] = [
 	'message' => '#^Method Drupal\\\\olivero\\\\OliveroPreRender\\:\\:textFormat\\(\\) has no return type specified\\.$#',
 	'identifier' => 'missingType.return',
diff --git a/core/lib/Drupal/Core/Render/theme.api.php b/core/lib/Drupal/Core/Render/theme.api.php
index a43abacddf8999b781cf133559aa1344d6ba47be..0d3cd45c9ea97a15899cbb3073e99ced297e4346 100644
--- a/core/lib/Drupal/Core/Render/theme.api.php
+++ b/core/lib/Drupal/Core/Render/theme.api.php
@@ -556,7 +556,7 @@ function hook_form_system_theme_settings_alter(&$form, \Drupal\Core\Form\FormSta
  * @param string $hook
  *   The name of the theme hook.
  */
-function hook_preprocess(&$variables, $hook) {
+function hook_preprocess(&$variables, $hook): void {
   static $hooks;
 
   // Add contextual links to the variables, if the user has permission.
@@ -807,7 +807,7 @@ function hook_themes_uninstalled(array $themes): void {
  * @return string
  *   The file extension the theme engine will recognize.
  */
-function hook_extension() {
+function hook_extension(): string {
   // Extension for template base names in Twig.
   return '.html.twig';
 }
@@ -833,7 +833,7 @@ function hook_extension() {
  *   The output generated from the template. In most cases this will be a string
  *   containing HTML markup.
  */
-function hook_render_template($template_file, $variables) {
+function hook_render_template($template_file, $variables): string|\Stringable {
   $twig_service = \Drupal::service('twig');
 
   return $twig_service->loadTemplate($template_file)->render($variables);
diff --git a/core/modules/comment/src/Hook/CommentHooks.php b/core/modules/comment/src/Hook/CommentHooks.php
index 67dcbd6c6e6eed78460c702edafe385754b610f1..196fdf6890b9eedd165f427b34092fd5a4c1e704 100644
--- a/core/modules/comment/src/Hook/CommentHooks.php
+++ b/core/modules/comment/src/Hook/CommentHooks.php
@@ -337,7 +337,7 @@ public function entityPredelete(EntityInterface $entity): void {
    * Implements hook_node_update_index().
    */
   #[Hook('node_update_index')]
-  public function nodeUpdateIndex(EntityInterface $node) {
+  public function nodeUpdateIndex(EntityInterface $node): string {
     $index_comments =& drupal_static('comment_node_update_index');
     if ($index_comments === NULL) {
       // Do not index in the following three cases:
diff --git a/core/modules/contextual/contextual.module b/core/modules/contextual/contextual.module
index a875584d1faf18cd16313e4a06b7b9e6ce89cd4f..5dcddfab211e0ede7aceb586aa83d0cb8aaae02c 100644
--- a/core/modules/contextual/contextual.module
+++ b/core/modules/contextual/contextual.module
@@ -14,7 +14,7 @@
  * @see contextual_page_attachments()
  * @see \Drupal\contextual\ContextualController::render()
  */
-function contextual_preprocess(&$variables, $hook, $info) {
+function contextual_preprocess(&$variables, $hook, $info): void {
   // Determine the primary theme function argument.
   if (!empty($info['variables'])) {
     $keys = array_keys($info['variables']);
diff --git a/core/modules/node/node.api.php b/core/modules/node/node.api.php
index 9823a2cdac7c3cd1625bae1c9b21698ae3fbb680..dac7282575fcfbf38076b252a468ec7cd0ae2597 100644
--- a/core/modules/node/node.api.php
+++ b/core/modules/node/node.api.php
@@ -315,12 +315,12 @@ function hook_node_search_result(NodeInterface $node): array {
  * @param \Drupal\node\NodeInterface $node
  *   The node being indexed.
  *
- * @return string
+ * @return string|\Stringable
  *   Additional node information to be indexed.
  *
  * @ingroup entity_crud
  */
-function hook_node_update_index(NodeInterface $node) {
+function hook_node_update_index(NodeInterface $node): string|\Stringable {
   $text = '';
   $ratings = \Drupal::database()->query('SELECT [title], [description] FROM {my_ratings} WHERE [nid] = :nid', [':nid' => $node->id()]);
   foreach ($ratings as $rating) {
diff --git a/core/modules/search/search.api.php b/core/modules/search/search.api.php
index 47744998e350fda32e59435c1c7d593aa311c0b7..4dfa804d607fab4da03642d7d23bde640e6b4057 100644
--- a/core/modules/search/search.api.php
+++ b/core/modules/search/search.api.php
@@ -46,7 +46,7 @@
  *
  * @ingroup search
  */
-function hook_search_preprocess($text, $langcode = NULL) {
+function hook_search_preprocess($text, $langcode = NULL): string {
   // If the language is not set, get it from the language manager.
   if (!isset($langcode)) {
     $langcode = \Drupal::languageManager()->getCurrentLanguage()->getId();
diff --git a/core/modules/search/tests/modules/search_langcode_test/src/Hook/SearchLangcodeTestHooks.php b/core/modules/search/tests/modules/search_langcode_test/src/Hook/SearchLangcodeTestHooks.php
index 6b09bde12a95ea795fc8d071c03b75eb9e28a8fc..626d5fe9779ce4d1928c9f10140286f80c203d11 100644
--- a/core/modules/search/tests/modules/search_langcode_test/src/Hook/SearchLangcodeTestHooks.php
+++ b/core/modules/search/tests/modules/search_langcode_test/src/Hook/SearchLangcodeTestHooks.php
@@ -15,7 +15,7 @@ class SearchLangcodeTestHooks {
    * Implements hook_search_preprocess().
    */
   #[Hook('search_preprocess')]
-  public function searchPreprocess($text, $langcode = NULL) {
+  public function searchPreprocess($text, $langcode = NULL): string {
     if (isset($langcode) && $langcode == 'en') {
       // Add the alternate verb forms for the word "testing".
       if ($text == 'we are testing') {
diff --git a/core/modules/system/tests/modules/deprecation_test/deprecation_test.module b/core/modules/system/tests/modules/deprecation_test/deprecation_test.module
index 8ed02e6d04318acd06e11c0166562cd0b7c9efb7..6e37d3c44b5a2d5014ac8a6092340d0c47d9dc0a 100644
--- a/core/modules/system/tests/modules/deprecation_test/deprecation_test.module
+++ b/core/modules/system/tests/modules/deprecation_test/deprecation_test.module
@@ -27,7 +27,7 @@ function deprecation_test_function() {
 /**
  * Implements hook_deprecated_hook().
  */
-function deprecation_test_deprecated_hook($arg) {
+function deprecation_test_deprecated_hook($arg): mixed {
   return $arg;
 }
 
diff --git a/core/modules/system/tests/modules/module_test/module_test.file.inc b/core/modules/system/tests/modules/module_test/module_test.file.inc
index df26b1b233944c3f73f93dcfc8298422d3336fcc..c0cee6f1905ee6faeee30988762808510b7a143a 100644
--- a/core/modules/system/tests/modules/module_test/module_test.file.inc
+++ b/core/modules/system/tests/modules/module_test/module_test.file.inc
@@ -13,6 +13,6 @@
 /**
  * Implements hook_test_hook().
  */
-function module_test_test_hook() {
+function module_test_test_hook(): array {
   return ['module_test' => 'success!'];
 }
diff --git a/core/modules/system/tests/modules/module_test/module_test.implementations.inc b/core/modules/system/tests/modules/module_test/module_test.implementations.inc
index 90c045e3f5922b4f7d9685df17780e6de9df286c..b971af58c8c1781b2ee9e0c53eceacc4a49b4c49 100644
--- a/core/modules/system/tests/modules/module_test/module_test.implementations.inc
+++ b/core/modules/system/tests/modules/module_test/module_test.implementations.inc
@@ -12,6 +12,6 @@
  *
  * @see module_test_module_implements_alter()
  */
-function module_test_altered_test_hook() {
+function module_test_altered_test_hook(): string {
   return __FUNCTION__;
 }
diff --git a/core/modules/system/tests/modules/module_test/module_test.module b/core/modules/system/tests/modules/module_test/module_test.module
index eb8af1a7dc90f38c875ecffd9a9bd90496297c10..b7f320a35e3c26b8f704cf593cad67d66e640ecf 100644
--- a/core/modules/system/tests/modules/module_test/module_test.module
+++ b/core/modules/system/tests/modules/module_test/module_test.module
@@ -81,7 +81,7 @@ function module_test_load($param) {
 /**
  * Implements hook_modules_installed().
  */
-function module_test_modules_installed($modules) {
+function module_test_modules_installed($modules): void {
   // Record the ordered list of modules that were passed in to this hook so we
   // can check that the modules were enabled in the correct sequence.
   \Drupal::state()->set('module_test.install_order', $modules);
@@ -90,7 +90,7 @@ function module_test_modules_installed($modules) {
 /**
  * Implements hook_modules_uninstalled().
  */
-function module_test_modules_uninstalled($modules) {
+function module_test_modules_uninstalled($modules): void {
   // Record the ordered list of modules that were passed in to this hook so we
   // can check that the modules were uninstalled in the correct sequence.
   \Drupal::state()->set('module_test.uninstall_order', $modules);
diff --git a/core/modules/system/tests/themes/engines/nyan_cat/nyan_cat.engine b/core/modules/system/tests/themes/engines/nyan_cat/nyan_cat.engine
index ec74b2aa1636800d07f70cc98712a752337fc2c5..4c63cf64d5a38798d3e40c6b165dbc29e44fa81b 100644
--- a/core/modules/system/tests/themes/engines/nyan_cat/nyan_cat.engine
+++ b/core/modules/system/tests/themes/engines/nyan_cat/nyan_cat.engine
@@ -21,14 +21,14 @@ function nyan_cat_theme($existing, $type, $theme, $path): array {
 /**
  * Implements hook_extension().
  */
-function nyan_cat_extension() {
+function nyan_cat_extension(): string {
   return '.nyan-cat.html';
 }
 
 /**
  * Implements hook_render_template().
  */
-function nyan_cat_render_template($template_file, $variables) {
+function nyan_cat_render_template($template_file, $variables): string {
   $output = str_replace('div', 'nyancat', file_get_contents(\Drupal::root() . '/' . $template_file));
   foreach ($variables as $key => $variable) {
     if (str_contains($output, '9' . $key)) {
diff --git a/core/modules/system/tests/themes/test_subtheme/test_subtheme.theme b/core/modules/system/tests/themes/test_subtheme/test_subtheme.theme
index 36065bfe4ea7bccdec873a73ed9a72b803764d35..d80189e0e63de0b03024d6f76de91cb931133601 100644
--- a/core/modules/system/tests/themes/test_subtheme/test_subtheme.theme
+++ b/core/modules/system/tests/themes/test_subtheme/test_subtheme.theme
@@ -13,7 +13,7 @@
 /**
  * Implements hook_views_pre_render().
  */
-function test_subtheme_views_pre_render(ViewExecutable $view) {
+function test_subtheme_views_pre_render(ViewExecutable $view): void {
   // We append the function name to the title for test to check for.
   $view->setTitle($view->getTitle() . ":" . __FUNCTION__);
 }
@@ -21,7 +21,7 @@ function test_subtheme_views_pre_render(ViewExecutable $view) {
 /**
  * Implements hook_views_post_render().
  */
-function test_subtheme_views_post_render(ViewExecutable $view, &$output, CachePluginBase $cache) {
+function test_subtheme_views_post_render(ViewExecutable $view, &$output, CachePluginBase $cache): void {
   // We append the function name to the title for test to check for.
   $view->setTitle($view->getTitle() . ":" . __FUNCTION__);
   if ($view->id() == 'test_page_display') {
diff --git a/core/modules/views/views.api.php b/core/modules/views/views.api.php
index cb62e66c32aba55e2b0e789f6825bc62d35bc6ee..4fbcad6730eac53c23d66087ac922eb79d0edbcd 100644
--- a/core/modules/views/views.api.php
+++ b/core/modules/views/views.api.php
@@ -843,7 +843,7 @@ function hook_views_post_execute(ViewExecutable $view) {
  *
  * @see \Drupal\views\ViewExecutable
  */
-function hook_views_pre_render(ViewExecutable $view) {
+function hook_views_pre_render(ViewExecutable $view): void {
   // Scramble the order of the rows shown on this result page.
   // Note that this could be done earlier, but not later in the view execution
   // process.
@@ -881,7 +881,7 @@ function hook_views_pre_render(ViewExecutable $view) {
  *
  * @see \Drupal\views\ViewExecutable
  */
-function hook_views_post_render(ViewExecutable $view, array &$output, CachePluginBase $cache) {
+function hook_views_post_render(ViewExecutable $view, array &$output, CachePluginBase $cache): void {
   // When using full pager, disable any time-based caching if there are fewer
   // than 10 results.
   if ($view->pager instanceof Full && $cache instanceof Time && count($view->result) < 10) {
diff --git a/core/themes/claro/claro.theme b/core/themes/claro/claro.theme
index bb2c903466201eb27122f2436db8d509a85d386e..c4a95ffbc6cdab5f97323cece6dfafd971eeb4b3 100644
--- a/core/themes/claro/claro.theme
+++ b/core/themes/claro/claro.theme
@@ -1605,7 +1605,7 @@ function claro_preprocess_fieldset__media_library_widget(array &$variables): voi
 /**
  * Implements hook_views_pre_render().
  */
-function claro_views_pre_render(ViewExecutable $view) {
+function claro_views_pre_render(ViewExecutable $view): void {
   $add_classes = function (&$option, array $classes_to_add) {
     $classes = preg_split('/\s+/', $option);
     $classes = array_filter($classes);
diff --git a/core/themes/engines/twig/twig.engine b/core/themes/engines/twig/twig.engine
index bcf68499adf05b71147ab6435749af3e63cabbaf..7ba1c275c64d88093362ff7897bba90093eb0400 100644
--- a/core/themes/engines/twig/twig.engine
+++ b/core/themes/engines/twig/twig.engine
@@ -5,6 +5,7 @@
  * Handles integration of Twig templates with the Drupal theme system.
  */
 
+use Drupal\Component\Render\MarkupInterface;
 use Drupal\Component\Utility\Html;
 use Drupal\Core\Render\Markup;
 use Twig\Error\RuntimeError;
@@ -19,14 +20,14 @@ function twig_theme($existing, $type, $theme, $path): array {
 /**
  * Implements hook_extension().
  */
-function twig_extension() {
+function twig_extension(): string {
   return '.html.twig';
 }
 
 /**
  * Implements hook_render_template().
  */
-function twig_render_template($template_file, array $variables) {
+function twig_render_template($template_file, array $variables): string|MarkupInterface {
   /** @var \Twig\Environment $twig_service */
   $twig_service = \Drupal::service('twig');
   try {