Skip to content
Merged
Show file tree
Hide file tree
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
5 changes: 2 additions & 3 deletions src/Analyser/ExprHandler/AssignHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -619,9 +619,6 @@ public function processAssignVar(
));

} else {
$offsetTypes[] = [$scope->getType($dimExpr), $dimFetch];
$offsetNativeTypes[] = [$scope->getNativeType($dimExpr), $dimFetch];

if ($enterExpressionAssign) {
$scope->enterExpressionAssign($dimExpr);
}
Expand All @@ -635,6 +632,8 @@ public function processAssignVar(
impurePoints: [],
));
$result = $nodeScopeResolver->processExprNode($stmt, $dimExpr, $scope, $storage, $nodeCallback, $context->enterDeep());
$offsetTypes[] = [$result->getType(), $dimFetch];
$offsetNativeTypes[] = [$result->getNativeType(), $dimFetch];
$hasYield = $hasYield || $result->hasYield();
$throwPoints = array_merge($throwPoints, $result->getThrowPoints());
$scope = $result->getScope();
Expand Down
6 changes: 4 additions & 2 deletions src/Analyser/ExprHandler/FuncCallHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,10 @@ public function processExpr(NodeScopeResolver $nodeScopeResolver, Stmt $stmt, Ex
$impurePoints = [];
$isAlwaysTerminating = false;
if ($expr->name instanceof Expr) {
$nameType = $scope->getType($expr->name);
// process the dynamic callee name first, then consume its type rather
// than reading it before processExprNode() stores its result
$nameResult = $nodeScopeResolver->processExprNode($stmt, $expr->name, $scope, $storage, $nodeCallback, $context->enterDeep());
$nameType = $nameResult->getType();
if (!$nameType->isCallable()->no()) {
$parametersAcceptor = ParametersAcceptorSelector::selectFromArgs(
$scope,
Expand All @@ -134,7 +137,6 @@ public function processExpr(NodeScopeResolver $nodeScopeResolver, Stmt $stmt, Ex
);
}

$nameResult = $nodeScopeResolver->processExprNode($stmt, $expr->name, $scope, $storage, $nodeCallback, $context->enterDeep());
$scope = $nameResult->getScope();
$throwPoints = $nameResult->getThrowPoints();
$impurePoints = $nameResult->getImpurePoints();
Expand Down
4 changes: 2 additions & 2 deletions src/Analyser/NodeScopeResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -1378,8 +1378,8 @@ public function processStmtNode(
$condScope = $scope;
foreach ($stmt->elseifs as $elseif) {
$this->callNodeCallback($nodeCallback, $elseif, $scope, $storage);
$elseIfConditionType = ($this->treatPhpDocTypesAsCertain ? $condScope->getType($elseif->cond) : $scope->getNativeType($elseif->cond))->toBoolean();
$condResult = $this->processExprNode($stmt, $elseif->cond, $condScope, $storage, $nodeCallback, ExpressionContext::createDeep());
$elseIfConditionType = ($this->treatPhpDocTypesAsCertain ? $condResult->getType() : $condResult->getNativeType())->toBoolean();
$throwPoints = array_merge($throwPoints, $condResult->getThrowPoints());
$impurePoints = array_merge($impurePoints, $condResult->getImpurePoints());
$branchScopeStatementResult = $this->processStmtNodesInternal($elseif, $elseif->stmts, $condResult->getTruthyScope(), $storage, $nodeCallback, $context);
Expand Down Expand Up @@ -1726,7 +1726,7 @@ public function processStmtNode(
$originalStorage = $storage;
$storage = $originalStorage->duplicate();
$condResult = $this->processExprNode($stmt, $stmt->cond, $scope, $storage, new NoopNodeCallback(), ExpressionContext::createDeep());
$beforeCondBooleanType = ($this->treatPhpDocTypesAsCertain ? $scope->getType($stmt->cond) : $scope->getNativeType($stmt->cond))->toBoolean();
$beforeCondBooleanType = ($this->treatPhpDocTypesAsCertain ? $condResult->getType() : $condResult->getNativeType())->toBoolean();
$condScope = $condResult->getFalseyScope();
if (!$context->isTopLevel() && $beforeCondBooleanType->isFalse()->yes()) {
if (!$this->polluteScopeWithLoopInitialAssignments) {
Expand Down
Loading