Skip to content

Commit 8874122

Browse files
committed
simplify
1 parent adff669 commit 8874122

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
@@ -357,12 +357,6 @@ public function setOffsetValueType(?Type $offsetType, Type $valueType, bool $uni
357357
public function setExistingOffsetValueType(Type $offsetType, Type $valueType): Type
358358
{
359359
if ($offsetType instanceof ConstantStringType || $offsetType instanceof ConstantIntegerType) {
360-
if ($offsetType->isSuperTypeOf($this->keyType)->yes()) {
361-
$builder = ConstantArrayTypeBuilder::createEmpty();
362-
$builder->setOffsetValueType($offsetType, $valueType);
363-
return $builder->getArray();
364-
}
365-
366360
return TypeCombinator::intersect(
367361
new self(
368362
TypeCombinator::union($this->keyType, $offsetType),

src/Type/Constant/ConstantArrayType.php

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

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

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

0 commit comments

Comments
 (0)