Skip to content

Commit

Permalink
Fix literal float and string comparisons
Browse files Browse the repository at this point in the history
  • Loading branch information
matt committed Feb 23, 2024
1 parent b5719ee commit 3a50880
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/Psalm/TypeComparator.php
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,10 @@ private static function isContainedByInheritance(Atomic $type, Atomic $container
return false;
}

if ($type instanceof TFloat && $container instanceof TLiteralFloat) {
return false;
}

if ($type instanceof TInt && $container instanceof TInt) {
return self::isContainedByInt($type, $container);
}
Expand Down Expand Up @@ -172,6 +176,9 @@ private static function isContainedByString(Atomic $type, Atomic $container): bo
if (! ($type instanceof TString && $container instanceof TString)) {
return false;
}
if ($type instanceof TLiteralString && $container instanceof TLiteralString) {
return $type->value === $container->value;
}

if ($type::class === $container::class) {
return true;
Expand Down

0 comments on commit 3a50880

Please sign in to comment.