Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 11 additions & 6 deletions src/Type/Accessory/AccessoryArrayListType.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,19 +79,17 @@ public function getConstantStrings(): array

public function accepts(Type $type, bool $strictTypes): AcceptsResult
{
$isArray = $type->isArray();
$isList = $type->isList();
$isListArray = $isArray->and($isList);

if ($isListArray->yes()) {
if ($isList->yes()) {
return AcceptsResult::createYes();
}

if ($type instanceof CompoundType) {
return $type->isAcceptedBy($this, $strictTypes);
}

return new AcceptsResult($isListArray, []);
return new AcceptsResult($isList, []);
}

public function isSuperTypeOf(Type $type): IsSuperTypeOfResult
Expand All @@ -104,7 +102,7 @@ public function isSuperTypeOf(Type $type): IsSuperTypeOfResult
return $type->isSubTypeOf($this);
}

return new IsSuperTypeOfResult($type->isArray()->and($type->isList()), []);
return new IsSuperTypeOfResult($type->isList(), []);
}

public function isSubTypeOf(Type $otherType): IsSuperTypeOfResult
Expand All @@ -113,8 +111,15 @@ public function isSubTypeOf(Type $otherType): IsSuperTypeOfResult
return $otherType->isSuperTypeOf($this);
}

if ($otherType instanceof self) {
return new IsSuperTypeOfResult(
TrinaryLogic::createYes(),
[],
);
}

return new IsSuperTypeOfResult(
$otherType->isArray()->and($otherType->isList())->and($otherType instanceof self ? TrinaryLogic::createYes() : TrinaryLogic::createMaybe()),
$otherType->isList()->and(TrinaryLogic::createMaybe()),
[],
);
}
Expand Down
Loading