Skip to content

Commit

Permalink
Review
Browse files Browse the repository at this point in the history
  • Loading branch information
VincentLanglet committed Jul 30, 2021
1 parent 501113c commit 761e29f
Showing 1 changed file with 2 additions and 14 deletions.
16 changes: 2 additions & 14 deletions src/Rules/RuleLevelHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,18 +77,8 @@ public function accepts(Type $acceptingType, Type $acceptedType, bool $strictTyp
$acceptedType = TypeCombinator::removeNull($acceptedType);
}

if ($acceptingType instanceof UnionType && !$acceptedType instanceof CompoundType) {
if (
$acceptedType->equals(new ObjectType(\DateTimeInterface::class))
&& $acceptingType->accepts(
new UnionType([new ObjectType(\DateTime::class), new ObjectType(\DateTimeImmutable::class)]),
$strictTypes
)->yes()
) {
return true;
}


$accepts = $acceptingType->accepts($acceptedType, $strictTypes);
if (!$accepts->yes() && $acceptingType instanceof UnionType && !$acceptedType instanceof CompoundType) {
foreach ($acceptingType->getTypes() as $innerType) {
if (self::accepts($innerType, $acceptedType, $strictTypes)) {
return true;
Expand Down Expand Up @@ -116,8 +106,6 @@ public function accepts(Type $acceptingType, Type $acceptedType, bool $strictTyp
);
}

$accepts = $acceptingType->accepts($acceptedType, $strictTypes);

return $this->checkUnionTypes ? $accepts->yes() : !$accepts->no();
}

Expand Down

0 comments on commit 761e29f

Please sign in to comment.