From 1eb0d1b3ab9554c8662abf45df9445eb9d70949a Mon Sep 17 00:00:00 2001 From: Martin Herndl Date: Sun, 2 Oct 2022 23:41:35 +0200 Subject: [PATCH] Remove IssetCheck/MutatingScope::issetCheck deviations and remove too early exits --- src/Analyser/MutatingScope.php | 14 +------------- src/Rules/IssetCheck.php | 4 ---- 2 files changed, 1 insertion(+), 17 deletions(-) diff --git a/src/Analyser/MutatingScope.php b/src/Analyser/MutatingScope.php index 6fb748b031..ab86b06337 100644 --- a/src/Analyser/MutatingScope.php +++ b/src/Analyser/MutatingScope.php @@ -1983,24 +1983,12 @@ private function issetCheck(Expr $expr, callable $typeCallback, ?bool $result = } if ($hasOffsetValue->no()) { - if ($result !== null) { - return $result; - } - return false; } - if ($hasOffsetValue->maybe()) { - return null; - } - // If offset is cannot be null, store this error message and see if one of the earlier offsets is. // E.g. $array['a']['b']['c'] ?? null; is a valid coalesce if a OR b or C might be null. - if ($hasOffsetValue->yes()) { - if ($result !== null) { - return $result; - } - + if ($hasOffsetValue->yes() || $this->isSpecified($expr)) { $result = $typeCallback($type->getOffsetValueType($dimType)); if ($result !== null) { diff --git a/src/Rules/IssetCheck.php b/src/Rules/IssetCheck.php index aa19b6607f..bf58da539d 100644 --- a/src/Rules/IssetCheck.php +++ b/src/Rules/IssetCheck.php @@ -68,10 +68,6 @@ public function check(Expr $expr, Scope $scope, string $operatorDescription, cal } if ($hasOffsetValue->no()) { - if ($error !== null) { - return $error; - } - if (!$this->checkAdvancedIsset) { return null; }