Bug #75182 [Opn->Csd]: Should DateTimeImmutable/DateTime throw a exception

From: Date: Fri, 01 Oct 2021 16:54:51 +0000
Subject: Bug #75182 [Opn->Csd]: Should DateTimeImmutable/DateTime throw a exception
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-236977@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=75182&edit=1 ID: 75182 Updated by: cmb@php.net Reported by: nyamsprod at gmail dot com Summary: Should DateTimeImmutable/DateTime throw a exception -Status: Open +Status: Closed Type: Bug Package: Date/time related PHP Version: Irrelevant -Assigned To: +Assigned To: cmb Block user comment: N Private report: N New Comment: This is fixed as of PHP 7.3.12 with the usual silent overflow semantics. Previous Comments: ------------------------------------------------------------------------ [2017-09-11 09:28:49] nyamsprod at gmail dot com Description: ------------ in PHP7.1+ DateInterval can take the number of microseconds, as a fraction of a second with the DateInterval::f public property. If DateInterval::f is set with a value greater than 1, DateInterval accepts it without warning. If we modify a DateTimeInterface object with this "invalid" DateInterval, a invalid DateTimeInterface object is returned. see https://3v4l.org/PcEMi Test script: --------------- $interval = new DateInterval('PT1S'); $interval->f = 500000; // excepted an Exception var_dump(date_create_immutable('2017-03-15')->add($interval)); // expected an OverflowException or a valid DateTimeInterface returns an Invalid DateTimeInterface object(DateTimeImmutable)#3 (3) { ["date"]=> string(31) "2017-03-15 00:00:03.-2147483648" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=75182&edit=1

« previous php.bugs (#236977) next »