Skip to content

Commit efce882

Browse files
mad-brillerondrejmirtes
authored andcommitted
Avoid doing work before its necessary in mutating scope.
1 parent d55c4f2 commit efce882

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

Diff for: src/Analyser/MutatingScope.php

+4-3
Original file line numberDiff line numberDiff line change
@@ -1119,11 +1119,11 @@ private function resolveType(string $exprString, Expr $node): Type
11191119
return new ObjectType(Closure::class);
11201120
}
11211121

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

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

20812081
if ($expr instanceof Node\Expr\ArrayDimFetch && $expr->dim !== null) {
20822082
$type = $this->getType($expr->var);
2083-
$dimType = $this->getType($expr->dim);
2084-
$hasOffsetValue = $type->hasOffsetValueType($dimType);
20852083
if (!$type->isOffsetAccessible()->yes()) {
20862084
return $this->issetCheckUndefined($expr->var);
20872085
}
20882086

2087+
$dimType = $this->getType($expr->dim);
2088+
$hasOffsetValue = $type->hasOffsetValueType($dimType);
2089+
20892090
if (!$hasOffsetValue->no()) {
20902091
return $this->issetCheckUndefined($expr->var);
20912092
}

0 commit comments

Comments
 (0)