Skip to content

Commit 879291b

Browse files
committed
degrade only maybe-arrays
1 parent 87f29af commit 879291b

1 file changed

Lines changed: 15 additions & 13 deletions

File tree

src/Analyser/MutatingScope.php

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2691,33 +2691,35 @@ public function specifyExpressionType(Expr $expr, Type $type, Type $nativeType,
26912691
$exprVarType = $scope->getType($expr->var);
26922692
$isArray = $exprVarType->isArray();
26932693
if (!$exprVarType instanceof MixedType && !$isArray->no()) {
2694+
$tooComplex = false;
2695+
26942696
$varType = $exprVarType;
26952697
if (!$isArray->yes()) {
26962698
if ($dimType->isInteger()->yes()) {
26972699
$varType = TypeCombinator::intersect($exprVarType, StaticTypeFactory::intOffsetAccessibleType());
26982700
} else {
26992701
$varType = TypeCombinator::intersect($exprVarType, StaticTypeFactory::generalOffsetAccessibleType());
27002702
}
2701-
}
27022703

2703-
$tooComplex = false;
2704-
if ($exprVarType instanceof UnionType) {
2705-
$hasOffsetAccessoryCount = 0;
2706-
foreach ($exprVarType->getTypes() as $innerType) {
2707-
foreach (TypeUtils::getAccessoryTypes($innerType) as $accessoryType) {
2708-
if (!($accessoryType instanceof HasOffsetValueType)) {
2709-
continue;
2710-
}
2704+
if ($exprVarType instanceof UnionType) {
2705+
$hasOffsetAccessoryCount = 0;
2706+
foreach ($exprVarType->getTypes() as $innerType) {
2707+
foreach (TypeUtils::getAccessoryTypes($innerType) as $accessoryType) {
2708+
if (!($accessoryType instanceof HasOffsetValueType)) {
2709+
continue;
2710+
}
27112711

2712-
$hasOffsetAccessoryCount++;
2712+
$hasOffsetAccessoryCount++;
27132713

2714-
if ($hasOffsetAccessoryCount > self::ARRAY_DIM_FETCH_UNION_HAS_OFFSET_VALUE_TYPE_LIMIT) {
2715-
$tooComplex = true;
2716-
break 2;
2714+
if ($hasOffsetAccessoryCount > self::ARRAY_DIM_FETCH_UNION_HAS_OFFSET_VALUE_TYPE_LIMIT) {
2715+
$tooComplex = true;
2716+
break 2;
2717+
}
27172718
}
27182719
}
27192720
}
27202721
}
2722+
27212723
if (
27222724
!$tooComplex
27232725
&& ($dimType instanceof ConstantIntegerType || $dimType instanceof ConstantStringType)

0 commit comments

Comments
 (0)