Skip to content

Commit c7b41b5

Browse files
committed
simplify IntersectionType->hasOffsetValueType
1 parent 7bd97d5 commit c7b41b5

1 file changed

Lines changed: 2 additions & 4 deletions

File tree

src/Type/IntersectionType.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -973,17 +973,15 @@ private function doHasOffsetValueType(Type $offsetType): TrinaryLogic
973973
}
974974
}
975975

976-
$result = $this->intersectResults(static fn (Type $type): TrinaryLogic => $type->hasOffsetValueType($offsetType));
977-
978-
if (!$result->yes() && $this->isCallable()->yes() && $this->isArray()->yes()) {
976+
if ($this->isCallable()->yes() && $this->isArray()->yes()) {
979977
$arrayKeyOffsetType = $offsetType->toArrayKey();
980978
$callableArrayOffsetType = new UnionType([new ConstantIntegerType(0), new ConstantIntegerType(1)]);
981979
if ($callableArrayOffsetType->isSuperTypeOf($arrayKeyOffsetType)->yes()) {
982980
return TrinaryLogic::createYes();
983981
}
984982
}
985983

986-
return $result;
984+
return $this->intersectResults(static fn (Type $type): TrinaryLogic => $type->hasOffsetValueType($offsetType));
987985
}
988986

989987
public function getOffsetValueType(Type $offsetType): Type

0 commit comments

Comments
 (0)