Merge branch 'PHP-8.1'

This commit is contained in:
Derick Rethans 2022-04-22 10:31:22 +01:00
commit a690a56a86

View File

@ -1,20 +1,24 @@
--TEST--
Bug #73837: Milliseconds in DateTime()
--SKIPIF--
<?php
if (getenv("SKIP_SLOW_TESTS")) die("skip slow test");
?>
--FILE--
<?php
$collect = [];
for ( $i = 0; $i < 1000; $i++ )
{
$a = new DateTime();
$key = "s" . $a->format( "u" );
$collect[$key] = true;
$startTS = time();
$prev_dt = new DateTime();
while (time() < $startTS + 2) {
$dt = new DateTime();
if ($prev_dt > $dt) {
var_dump($prev_dt->format("Y-m-d H:i:s.u"));
var_dump($dt->format("Y-m-d H:i:s.u"));
break;
}
$prev_dt = $dt;
}
// For low-resolution clocks, we may construct many objects in the same tick.
var_dump($n = count( $collect ));
echo $n > 200 ? "microseconds differ\n" : "microseconds do not differ enough ($n)\n";
echo "Finished\n";
?>
--EXPECTF--
int(%d)
microseconds differ
Finished