|
173 | 173 | use PHPStan\Type\Constant\ConstantArrayTypeBuilder;
|
174 | 174 | use PHPStan\Type\Constant\ConstantIntegerType;
|
175 | 175 | use PHPStan\Type\Constant\ConstantStringType;
|
176 |
| -use PHPStan\Type\ErrorType; |
177 | 176 | use PHPStan\Type\FileTypeMapper;
|
178 | 177 | use PHPStan\Type\GeneralizePrecision;
|
179 | 178 | use PHPStan\Type\Generic\TemplateTypeHelper;
|
@@ -6157,12 +6156,17 @@ private function produceArrayDimFetchAssignValueToWrite(array $dimFetchStack, ar
|
6157 | 6156 | $offsetValueType = new ConstantArrayType([], []);
|
6158 | 6157 |
|
6159 | 6158 | } else {
|
6160 |
| - $add = $offsetValueType->hasOffsetValueType($offsetType)->maybe(); |
6161 |
| - $offsetValueType = $offsetValueType->getOffsetValueType($offsetType); |
6162 |
| - if ($offsetValueType instanceof ErrorType) { |
| 6159 | + $has = $offsetValueType->hasOffsetValueType($offsetType); |
| 6160 | + if ($has->yes()) { |
| 6161 | + $offsetValueType = $offsetValueType->getOffsetValueType($offsetType); |
| 6162 | + } elseif ($has->maybe()) { |
| 6163 | + if (!$scope->hasExpressionType($dimFetch)->yes()) { |
| 6164 | + $offsetValueType = TypeCombinator::union($offsetValueType->getOffsetValueType($offsetType), new ConstantArrayType([], [])); |
| 6165 | + } else { |
| 6166 | + $offsetValueType = $offsetValueType->getOffsetValueType($offsetType); |
| 6167 | + } |
| 6168 | + } else { |
6163 | 6169 | $offsetValueType = new ConstantArrayType([], []);
|
6164 |
| - } elseif ($add && !$scope->hasExpressionType($dimFetch)->yes()) { |
6165 |
| - $offsetValueType = TypeCombinator::union($offsetValueType, new ConstantArrayType([], [])); |
6166 | 6170 | }
|
6167 | 6171 | }
|
6168 | 6172 |
|
|
0 commit comments