From 985b1efaef10b5cbd2b36d15bb883fe168f0f681 Mon Sep 17 00:00:00 2001
From: Lauri Eskola <lauri.eskola@acquia.com>
Date: Sat, 22 Jul 2023 11:14:41 +0300
Subject: [PATCH] Issue #3374878 by Spokje: Fix PHPStan L1 errors "Offset 'foo'
 on array{} in isset() does not exist."

---
 .../tests/src/Kernel/Handler/AreaDisplayLinkTest.php   |  4 +++-
 .../views/tests/src/Kernel/Handler/AreaEntityTest.php  |  4 +++-
 core/phpstan-baseline.neon                             | 10 ----------
 3 files changed, 6 insertions(+), 12 deletions(-)

diff --git a/core/modules/views/tests/src/Kernel/Handler/AreaDisplayLinkTest.php b/core/modules/views/tests/src/Kernel/Handler/AreaDisplayLinkTest.php
index 659e1490efb7..c0d22081403b 100644
--- a/core/modules/views/tests/src/Kernel/Handler/AreaDisplayLinkTest.php
+++ b/core/modules/views/tests/src/Kernel/Handler/AreaDisplayLinkTest.php
@@ -308,7 +308,9 @@ public function testAreaDisplayLink() {
   protected function assertFormOptions(ViewExecutable $view, string $display_link_id): void {
     $form = [];
     $form_state = new FormState();
-    $view->display_handler->getHandler('header', $display_link_id)->buildOptionsForm($form, $form_state);
+    /** @var \Drupal\views\Plugin\views\area\DisplayLink $display_handler */
+    $display_handler = $view->display_handler->getHandler('header', $display_link_id);
+    $display_handler->buildOptionsForm($form, $form_state);
     $this->assertTrue(isset($form['display_id']['#options']['page_1']));
     $this->assertTrue(isset($form['display_id']['#options']['page_2']));
     $this->assertFalse(isset($form['display_id']['#options']['block_1']));
diff --git a/core/modules/views/tests/src/Kernel/Handler/AreaEntityTest.php b/core/modules/views/tests/src/Kernel/Handler/AreaEntityTest.php
index 786ebbb7a343..ba181188b186 100644
--- a/core/modules/views/tests/src/Kernel/Handler/AreaEntityTest.php
+++ b/core/modules/views/tests/src/Kernel/Handler/AreaEntityTest.php
@@ -179,7 +179,9 @@ public function doTestRender($entities) {
     $form = [];
     $form_state = (new FormState())
       ->set('type', 'header');
-    $view->display_handler->getHandler('header', 'entity_entity_test')->buildOptionsForm($form, $form_state);
+    /** @var \Drupal\views\Plugin\views\area\DisplayLink $display_handler */
+    $display_handler = $view->display_handler->getHandler('header', 'entity_entity_test');
+    $display_handler->buildOptionsForm($form, $form_state);
     $this->assertTrue(isset($form['view_mode']['#options']['test']), 'Ensure that the test view mode is available.');
     $this->assertTrue(isset($form['view_mode']['#options']['default']), 'Ensure that the default view mode is available.');
   }
diff --git a/core/phpstan-baseline.neon b/core/phpstan-baseline.neon
index c07643e8e503..3feadffd44a0 100644
--- a/core/phpstan-baseline.neon
+++ b/core/phpstan-baseline.neon
@@ -2445,16 +2445,6 @@ parameters:
 			count: 2
 			path: modules/views/tests/src/FunctionalJavascript/ClickSortingAJAXTest.php
 
-		-
-			message: "#^Offset 'display_id' on array\\{\\} in isset\\(\\) does not exist\\.$#"
-			count: 1
-			path: modules/views/tests/src/Kernel/Handler/AreaDisplayLinkTest.php
-
-		-
-			message: "#^Offset 'view_mode' on array\\{\\} in isset\\(\\) does not exist\\.$#"
-			count: 1
-			path: modules/views/tests/src/Kernel/Handler/AreaEntityTest.php
-
 		-
 			message: "#^Call to deprecated constant REQUEST_TIME\\: Deprecated in drupal\\:8\\.3\\.0 and is removed from drupal\\:11\\.0\\.0\\. Use \\\\Drupal\\:\\:time\\(\\)\\-\\>getRequestTime\\(\\); $#"
 			count: 3
-- 
GitLab