Skip to content

Commit

Permalink
Remove NonEmptyArrayType after unset()
Browse files Browse the repository at this point in the history
  • Loading branch information
ondrejmirtes committed Aug 24, 2020
1 parent b290a73 commit e96481c
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/Analyser/MutatingScope.php
Original file line number Diff line number Diff line change
Expand Up @@ -2879,7 +2879,8 @@ public function unsetExpression(Expr $expr): self
$nativeTypes
);
} elseif ($expr instanceof Expr\ArrayDimFetch && $expr->dim !== null) {
$constantArrays = TypeUtils::getConstantArrays($this->getType($expr->var));
$varType = $this->getType($expr->var);
$constantArrays = TypeUtils::getConstantArrays($varType);
if (count($constantArrays) > 0) {
$unsetArrays = [];
$dimType = $this->getType($expr->dim);
Expand All @@ -2894,7 +2895,13 @@ public function unsetExpression(Expr $expr): self

$args = [new Node\Arg($expr->var)];

return $this->invalidateExpression($expr->var)
$arrays = TypeUtils::getArrays($varType);
$scope = $this;
if (count($arrays) > 0) {
$scope = $scope->specifyExpressionType($expr->var, TypeCombinator::union(...$arrays));
}

return $scope->invalidateExpression($expr->var)
->invalidateExpression(new FuncCall(new Name\FullyQualified('count'), $args))
->invalidateExpression(new FuncCall(new Name('count'), $args));
}
Expand Down

0 comments on commit e96481c

Please sign in to comment.