Skip to content

Commit 3b734e2

Browse files
committed
simplify
1 parent 079610b commit 3b734e2

File tree

2 files changed

+1
-20
lines changed

2 files changed

+1
-20
lines changed

src/Type/ArrayType.php

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -362,12 +362,6 @@ public function setOffsetValueType(?Type $offsetType, Type $valueType, bool $uni
362362
public function setExistingOffsetValueType(Type $offsetType, Type $valueType): Type
363363
{
364364
if ($offsetType instanceof ConstantStringType || $offsetType instanceof ConstantIntegerType) {
365-
if ($offsetType->isSuperTypeOf($this->keyType)->yes()) {
366-
$builder = ConstantArrayTypeBuilder::createEmpty();
367-
$builder->setOffsetValueType($offsetType, $valueType);
368-
return $builder->getArray();
369-
}
370-
371365
return TypeCombinator::intersect(
372366
new self(
373367
TypeCombinator::union($this->keyType, $offsetType),

src/Type/Constant/ConstantArrayType.php

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -693,21 +693,8 @@ public function setOffsetValueType(?Type $offsetType, Type $valueType, bool $uni
693693

694694
public function setExistingOffsetValueType(Type $offsetType, Type $valueType): Type
695695
{
696-
$offsetType = $offsetType->toArrayKey();
697696
$builder = ConstantArrayTypeBuilder::createFromConstantArray($this);
698-
$unionValues = $offsetType instanceof UnionType && count($offsetType->getTypes()) > 1;
699-
foreach ($this->keyTypes as $keyType) {
700-
if ($offsetType->isSuperTypeOf($keyType)->no()) {
701-
continue;
702-
}
703-
704-
if ($unionValues) {
705-
$builder->setOffsetValueType($keyType, TypeCombinator::union($this->getOffsetValueType($keyType), $valueType));
706-
continue;
707-
}
708-
709-
$builder->setOffsetValueType($keyType, $valueType);
710-
}
697+
$builder->setOffsetValueType($offsetType, $valueType);
711698

712699
return $builder->getArray();
713700
}

0 commit comments

Comments
 (0)