From cc97afe40dddd7beffd24320abc3ac718c4d4b85 Mon Sep 17 00:00:00 2001
From: Dave Long <dave@longwaveconsulting.com>
Date: Thu, 22 Jun 2023 14:11:59 +0100
Subject: [PATCH] Issue #3359048 by Spokje, smustgrave: Fix PHPStan L1 errors
 "Cannot unset offset 'foo' on array<int, string>."

---
 core/modules/taxonomy/src/TermStorage.php |  1 +
 core/phpstan-baseline.neon                | 30 -----------------------
 2 files changed, 1 insertion(+), 30 deletions(-)

diff --git a/core/modules/taxonomy/src/TermStorage.php b/core/modules/taxonomy/src/TermStorage.php
index 061abd39e4ab..e121a1744a3a 100644
--- a/core/modules/taxonomy/src/TermStorage.php
+++ b/core/modules/taxonomy/src/TermStorage.php
@@ -449,6 +449,7 @@ public function getVocabularyHierarchyType($vid) {
    * {@inheritdoc}
    */
   public function __sleep() {
+    /** @var string[] $vars */
     $vars = parent::__sleep();
     // Do not serialize static cache.
     unset($vars['ancestors'], $vars['treeChildren'], $vars['treeParents'], $vars['treeTerms'], $vars['trees'], $vars['vocabularyHierarchyType']);
diff --git a/core/phpstan-baseline.neon b/core/phpstan-baseline.neon
index e1e023376cc7..6ad81f0594f5 100644
--- a/core/phpstan-baseline.neon
+++ b/core/phpstan-baseline.neon
@@ -2030,36 +2030,6 @@ parameters:
 			count: 1
 			path: modules/taxonomy/src/TermForm.php
 
-		-
-			message: "#^Cannot unset offset 'ancestors' on array\\<int, string\\>\\.$#"
-			count: 1
-			path: modules/taxonomy/src/TermStorage.php
-
-		-
-			message: "#^Cannot unset offset 'treeChildren' on array\\<int, string\\>\\.$#"
-			count: 1
-			path: modules/taxonomy/src/TermStorage.php
-
-		-
-			message: "#^Cannot unset offset 'treeParents' on array\\<int, string\\>\\.$#"
-			count: 1
-			path: modules/taxonomy/src/TermStorage.php
-
-		-
-			message: "#^Cannot unset offset 'treeTerms' on array\\<int, string\\>\\.$#"
-			count: 1
-			path: modules/taxonomy/src/TermStorage.php
-
-		-
-			message: "#^Cannot unset offset 'trees' on array\\<int, string\\>\\.$#"
-			count: 1
-			path: modules/taxonomy/src/TermStorage.php
-
-		-
-			message: "#^Cannot unset offset 'vocabularyHierarchy…' on array\\<int, string\\>\\.$#"
-			count: 1
-			path: modules/taxonomy/src/TermStorage.php
-
 		-
 			message: "#^Method Drupal\\\\taxonomy\\\\VocabularyForm\\:\\:save\\(\\) should return int but return statement is missing\\.$#"
 			count: 1
-- 
GitLab