Skip to content

Commit a81b0e8

Browse files
Simplify
1 parent fed2702 commit a81b0e8

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

src/Analyser/TypeSpecifier.php

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -929,23 +929,24 @@ public function specifyTypesInCondition(
929929
$dimType = $scope->getType($issetExpr->dim);
930930

931931
if ($dimType instanceof ConstantIntegerType || $dimType instanceof ConstantStringType) {
932-
$types = $varType instanceof UnionType ? $varType->getTypes() : [$varType];
932+
$constantArrays = $varType->getConstantArrays();
933933
$typesToRemove = [];
934-
foreach ($types as $innerType) {
935-
$hasOffset = $innerType->hasOffsetValueType($dimType);
936-
if (!$hasOffset->yes() || !$innerType->getOffsetValueType($dimType)->isNull()->no()) {
934+
foreach ($constantArrays as $constantArray) {
935+
$hasOffset = $constantArray->hasOffsetValueType($dimType);
936+
if (!$hasOffset->yes() || !$constantArray->getOffsetValueType($dimType)->isNull()->no()) {
937937
continue;
938938
}
939939

940-
$typesToRemove[] = $innerType;
940+
$typesToRemove[] = $constantArray;
941941
}
942942

943943
if ($typesToRemove !== []) {
944944
$typeToRemove = TypeCombinator::union(...$typesToRemove);
945+
945946
$result = $this->create(
946947
$issetExpr->var,
947948
$typeToRemove,
948-
TypeSpecifierContext::createFalse(),
949+
$context,
949950
$scope,
950951
)->setRootExpr($expr);
951952

@@ -954,7 +955,7 @@ public function specifyTypesInCondition(
954955
$this->create(
955956
new IssetExpr($issetExpr->var),
956957
new NullType(),
957-
TypeSpecifierContext::createTruthy(),
958+
$context->negate(),
958959
$scope,
959960
)->setRootExpr($expr),
960961
);

0 commit comments

Comments
 (0)