Skip to content

Commit

Permalink
Remove IssetCheck/MutatingScope::issetCheck deviations and remove too…
Browse files Browse the repository at this point in the history
… early exits
  • Loading branch information
herndlm authored and ondrejmirtes committed Oct 3, 2022
1 parent 8778350 commit 1eb0d1b
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 17 deletions.
14 changes: 1 addition & 13 deletions src/Analyser/MutatingScope.php
Expand Up @@ -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) {
Expand Down
4 changes: 0 additions & 4 deletions src/Rules/IssetCheck.php
Expand Up @@ -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;
}
Expand Down

0 comments on commit 1eb0d1b

Please sign in to comment.