1
0
mirror of https://github.com/php/php-src.git synced 2026-03-24 00:02:20 +01:00
Files
archived-php-src/ext/date/tests/bug70810.phpt
Nikita Popov 3cfbbf2956 Make DateInterval objects uncomparable
Arbitrary DateInterval objects don't have well-defined comparison
semantics. Throw a warning and treat the objects as uncomparable.

Support for comparing DateInterval objects returned by
DateTime::diff() may be added in the future.
2019-04-23 13:12:06 +02:00

36 lines
770 B
PHP

--TEST--
Bug #70810: DateInterval equals every other DateInterval
--FILE--
<?php
$i1 = new DateInterval('P1D');
$i2 = new DateInterval('PT1H');
var_dump($i1 == $i2);
var_dump($i1 < $i2);
var_dump($i1 > $i2);
$i2 = new DateInterval('P1D');
var_dump($i1 == $i2);
var_dump($i1 < $i2);
var_dump($i1 > $i2);
?>
--EXPECTF--
Warning: Cannot compare DateInterval objects in %s on line %d
bool(false)
Warning: Cannot compare DateInterval objects in %s on line %d
bool(false)
Warning: Cannot compare DateInterval objects in %s on line %d
bool(false)
Warning: Cannot compare DateInterval objects in %s on line %d
bool(false)
Warning: Cannot compare DateInterval objects in %s on line %d
bool(false)
Warning: Cannot compare DateInterval objects in %s on line %d
bool(false)