From df4592ec0416aee7c9b758de56d7bd0f6443bf3a Mon Sep 17 00:00:00 2001 From: Jan Oravec Date: Fri, 26 Jan 2024 13:36:21 -0800 Subject: [PATCH] Type get_class() arg as nonnull in typechecker Summary: Hopefully this will prevent some code from passing a null. Reviewed By: mdko Differential Revision: D53099289 fbshipit-source-id: 2fa9cdda572080d9660a32cadd1f5d97e06918f6 --- src/legacy_fixme/coercions.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/legacy_fixme/coercions.php b/src/legacy_fixme/coercions.php index cb60b969..acd69374 100644 --- a/src/legacy_fixme/coercions.php +++ b/src/legacy_fixme/coercions.php @@ -328,7 +328,10 @@ function __cast_and_compare(mixed $l, mixed $r, COMPARISON_TYPE $ctype)[]: int { $ctype === COMPARISON_TYPE::GT && \is_object($ri) && \is_object($li) && - (\get_class($li) !== \get_class($ri) || $li is \Closure) && + ( + \get_class($li as nonnull) !== \get_class($ri as nonnull) || + $li is \Closure + ) && !($li is \DateTimeInterface && $ri is \DateTimeInterface) ) { // flip the result :p