Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 17 additions & 5 deletions src/Analyser/MutatingScope.php
Original file line number Diff line number Diff line change
Expand Up @@ -945,7 +945,7 @@ private function resolveType(string $exprString, Expr $node): Type
!$node instanceof Variable
&& !$node instanceof Expr\Closure
&& !$node instanceof Expr\ArrowFunction
&& $this->hasExpressionType($node)->yes()
&& $this->hasExpressionTypeByString($exprString, $node)->yes()
) {
return $this->expressionTypes[$exprString]->getType();
}
Expand Down Expand Up @@ -2074,10 +2074,11 @@ static function (Node $node, Scope $scope) use ($arrowScope, &$arrowFunctionImpu
continue;
}
$constFetch = new ConstFetch($name);
if ($this->hasExpressionType($constFetch)->yes()) {
$constExprString = $this->getNodeKey($constFetch);
if ($this->hasExpressionTypeByString($constExprString, $constFetch)->yes()) {
return $this->constantResolver->resolveConstantType(
$name->toString(),
$this->expressionTypes[$this->getNodeKey($constFetch)]->getType(),
$this->expressionTypes[$constExprString]->getType(),
);
}
}
Expand All @@ -2089,7 +2090,7 @@ static function (Node $node, Scope $scope) use ($arrowScope, &$arrowFunctionImpu

return new ErrorType();
} elseif ($node instanceof Node\Expr\ClassConstFetch && $node->name instanceof Node\Identifier) {
if ($this->hasExpressionType($node)->yes()) {
if ($this->hasExpressionTypeByString($exprString, $node)->yes()) {
return $this->expressionTypes[$exprString]->getType();
}
return $this->initializerExprTypeResolver->getClassConstFetchTypeByReflection(
Expand Down Expand Up @@ -2924,7 +2925,18 @@ public function hasExpressionType(Expr $node): TrinaryLogic
return $this->hasVariableType($node->name);
}

$exprString = $this->getNodeKey($node);
return $this->hasExpressionTypeByString(
$this->getNodeKey($node),
$node,
);
}

private function hasExpressionTypeByString(string $exprString, Expr $node): TrinaryLogic
{
if ($node instanceof Variable) {
throw new ShouldNotHappenException();
}

if (!isset($this->expressionTypes[$exprString])) {
return TrinaryLogic::createNo();
}
Expand Down
Loading