Skip to content

Commit ec26bc5

Browse files
committed
remove unnecessary isSuperTypeOf check
1 parent 616d08a commit ec26bc5

1 file changed

Lines changed: 7 additions & 10 deletions

File tree

src/Type/IntersectionType.php

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1004,17 +1004,14 @@ private function doGetOffsetValueType(Type $offsetType): Type
10041004

10051005
if ($this->isCallable()->yes() && $this->isArray()->yes()) {
10061006
$arrayKeyOffsetType = $offsetType->toArrayKey();
1007-
$callableArrayOffsetType = new UnionType([new ConstantIntegerType(0), new ConstantIntegerType(1)]);
1008-
if ($callableArrayOffsetType->isSuperTypeOf($arrayKeyOffsetType)->yes()) {
1009-
if ((new ConstantIntegerType(0))->isSuperTypeOf($arrayKeyOffsetType)->yes()) {
1010-
$narrowedType = new UnionType([new ClassStringType(), new ObjectWithoutClassType()]);
1011-
} elseif ((new ConstantIntegerType(1))->isSuperTypeOf($arrayKeyOffsetType)->yes()) {
1012-
$narrowedType = new IntersectionType([new StringType(), new AccessoryNonFalsyStringType()]);
1013-
} else {
1014-
$narrowedType = new UnionType([new IntersectionType([new StringType(), new AccessoryNonFalsyStringType()]), new ObjectWithoutClassType()]);
1015-
}
1016-
$result = TypeCombinator::intersect($result, $narrowedType);
1007+
if ((new ConstantIntegerType(0))->isSuperTypeOf($arrayKeyOffsetType)->yes()) {
1008+
$narrowedType = new UnionType([new ClassStringType(), new ObjectWithoutClassType()]);
1009+
} elseif ((new ConstantIntegerType(1))->isSuperTypeOf($arrayKeyOffsetType)->yes()) {
1010+
$narrowedType = new IntersectionType([new StringType(), new AccessoryNonFalsyStringType()]);
1011+
} else {
1012+
$narrowedType = new UnionType([new IntersectionType([new StringType(), new AccessoryNonFalsyStringType()]), new ObjectWithoutClassType()]);
10171013
}
1014+
$result = TypeCombinator::intersect($result, $narrowedType);
10181015
}
10191016

10201017
return $result;

0 commit comments

Comments
 (0)