From 2170e97e6d122bbd3c3693658c23e800b1d88530 Mon Sep 17 00:00:00 2001
From: catch <catch56@gmail.com>
Date: Fri, 21 Oct 2022 07:32:15 +0100
Subject: [PATCH] Issue #3316276 by mondrake: Fix 'undefined variable' PHPStan
 L0 errors

---
 .../views/argument/IndexTidDepthModifier.php     |  4 ----
 .../src/Plugin/views/argument_validator/None.php |  2 +-
 .../Plugin/views/relationship/EntityReverse.php  | 16 ++--------------
 core/phpstan-baseline.neon                       | 15 ---------------
 4 files changed, 3 insertions(+), 34 deletions(-)

diff --git a/core/modules/taxonomy/src/Plugin/views/argument/IndexTidDepthModifier.php b/core/modules/taxonomy/src/Plugin/views/argument/IndexTidDepthModifier.php
index 65af6623be71..99ca4393c95d 100644
--- a/core/modules/taxonomy/src/Plugin/views/argument/IndexTidDepthModifier.php
+++ b/core/modules/taxonomy/src/Plugin/views/argument/IndexTidDepthModifier.php
@@ -53,10 +53,6 @@ public function preQuery() {
         continue;
       }
 
-      if (isset($handler)) {
-        unset($handler);
-      }
-
       $handler = &$this->view->argument[$key];
       if (empty($handler->definition['accept depth modifier'])) {
         continue;
diff --git a/core/modules/views/src/Plugin/views/argument_validator/None.php b/core/modules/views/src/Plugin/views/argument_validator/None.php
index 8e8c96571f28..c74f5290d121 100644
--- a/core/modules/views/src/Plugin/views/argument_validator/None.php
+++ b/core/modules/views/src/Plugin/views/argument_validator/None.php
@@ -23,7 +23,7 @@ public function validateArgument($argument) {
       return FALSE;
     }
 
-    if (!empty($this->argument->definition['numeric']) && !isset($this->argument->options['break_phrase']) && !is_numeric($arg)) {
+    if (!empty($this->argument->definition['numeric']) && !isset($this->argument->options['break_phrase'])) {
       return FALSE;
     }
 
diff --git a/core/modules/views/src/Plugin/views/relationship/EntityReverse.php b/core/modules/views/src/Plugin/views/relationship/EntityReverse.php
index 9ebba38603e2..64c3d7055784 100644
--- a/core/modules/views/src/Plugin/views/relationship/EntityReverse.php
+++ b/core/modules/views/src/Plugin/views/relationship/EntityReverse.php
@@ -79,13 +79,7 @@ public function query() {
       $first['extra'] = $this->definition['join_extra'];
     }
 
-    if (!empty($def['join_id'])) {
-      $id = $def['join_id'];
-    }
-    else {
-      $id = 'standard';
-    }
-    $first_join = $this->joinManager->createInstance($id, $first);
+    $first_join = $this->joinManager->createInstance('standard', $first);
 
     $this->first_alias = $this->query->addTable($this->definition['field table'], $this->relationship, $first_join);
 
@@ -103,13 +97,7 @@ public function query() {
       $second['type'] = 'INNER';
     }
 
-    if (!empty($def['join_id'])) {
-      $id = $def['join_id'];
-    }
-    else {
-      $id = 'standard';
-    }
-    $second_join = $this->joinManager->createInstance($id, $second);
+    $second_join = $this->joinManager->createInstance('standard', $second);
     $second_join->adjusted = TRUE;
 
     // use a short alias for this:
diff --git a/core/phpstan-baseline.neon b/core/phpstan-baseline.neon
index beb105701dc4..133943b68e1c 100644
--- a/core/phpstan-baseline.neon
+++ b/core/phpstan-baseline.neon
@@ -1145,11 +1145,6 @@ parameters:
 			count: 1
 			path: modules/taxonomy/src/Plugin/migrate/source/d7/TermTranslation.php
 
-		-
-			message: "#^Call to function unset\\(\\) contains undefined variable \\$handler\\.$#"
-			count: 1
-			path: modules/taxonomy/src/Plugin/views/argument/IndexTidDepthModifier.php
-
 		-
 			message: "#^Method Drupal\\\\taxonomy\\\\TermForm\\:\\:save\\(\\) should return int but return statement is missing\\.$#"
 			count: 1
@@ -1305,11 +1300,6 @@ parameters:
 			count: 1
 			path: modules/views/src/Plugin/views/argument/Date.php
 
-		-
-			message: "#^Undefined variable\\: \\$arg$#"
-			count: 1
-			path: modules/views/src/Plugin/views/argument_validator/None.php
-
 		-
 			message: "#^Method Drupal\\\\views\\\\Plugin\\\\views\\\\cache\\\\CachePluginBase\\:\\:cacheGet\\(\\) should return bool but return statement is missing\\.$#"
 			count: 1
@@ -1355,11 +1345,6 @@ parameters:
 			count: 2
 			path: modules/views/src/Plugin/views/filter/FilterPluginBase.php
 
-		-
-			message: "#^Undefined variable\\: \\$def$#"
-			count: 2
-			path: modules/views/src/Plugin/views/relationship/EntityReverse.php
-
 		-
 			message: "#^Call to deprecated constant REQUEST_TIME\\: Deprecated in drupal\\:8\\.3\\.0 and is removed from drupal\\:10\\.0\\.0\\. Use \\\\Drupal\\:\\:time\\(\\)\\-\\>getRequestTime\\(\\); $#"
 			count: 1
-- 
GitLab