Skip to content

Commit

Permalink
Avoid doing work before its necessary in mutating scope.
Browse files Browse the repository at this point in the history
  • Loading branch information
mad-briller authored and ondrejmirtes committed Jul 19, 2023
1 parent d55c4f2 commit efce882
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/Analyser/MutatingScope.php
Original file line number Diff line number Diff line change
Expand Up @@ -1119,11 +1119,11 @@ private function resolveType(string $exprString, Expr $node): Type
return new ObjectType(Closure::class);
}

$classType = $this->resolveTypeByName($node->class);
if (!$node->name instanceof Node\Identifier) {
return new ObjectType(Closure::class);
}

$classType = $this->resolveTypeByName($node->class);
$methodName = $node->name->toString();
if (!$classType->hasMethod($methodName)->yes()) {
return new ObjectType(Closure::class);
Expand Down Expand Up @@ -2080,12 +2080,13 @@ private function issetCheckUndefined(Expr $expr): ?bool

if ($expr instanceof Node\Expr\ArrayDimFetch && $expr->dim !== null) {
$type = $this->getType($expr->var);
$dimType = $this->getType($expr->dim);
$hasOffsetValue = $type->hasOffsetValueType($dimType);
if (!$type->isOffsetAccessible()->yes()) {
return $this->issetCheckUndefined($expr->var);
}

$dimType = $this->getType($expr->dim);
$hasOffsetValue = $type->hasOffsetValueType($dimType);

if (!$hasOffsetValue->no()) {
return $this->issetCheckUndefined($expr->var);
}
Expand Down

0 comments on commit efce882

Please sign in to comment.