Bug #78509 [Nab]: Calling time() with parameter(s) returns NULL

From: Date: Sat, 07 Sep 2019 18:19:10 +0000
Subject: Bug #78509 [Nab]: Calling time() with parameter(s) returns NULL
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-222625@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=78509&edit=1 ID: 78509 User updated by: gvre at gvre dot gr Reported by: gvre at gvre dot gr Summary: Calling time() with parameter(s) returns NULL Status: Not a bug Type: Bug Package: Date/time related PHP Version: 7.3 Block user comment: N Private report: N New Comment: It is very good that PHP 8 will be throwing an ArgumentCountError in such cases, but the change introduced in 7.3 breaks code that works in all previous versions (4.3.0 - 7.2.22). Ideally, 7.3 should be creating a warning and a later version be stricter if needed. It would also be helpful for people who want to upgrade to be aware of that change. Previous Comments: ------------------------------------------------------------------------ [2019-09-07 15:04:37] girgias@php.net This is not a bug on PHP's side, moreover this will throw an ArgumentCountError as of PHP 8. [1] [1] https://wiki.php.net/rfc/consistent_type_errors ------------------------------------------------------------------------ [2019-09-07 12:25:24] gvre at gvre dot gr Description: ------------ Calling the "time()" function with a parameter works fine in PHP <= 7.2.x and returns an int. In PHP 7.3, it returns NULL and produces a "Warning: time() expects exactly 0 parameters, 1 given" message instead. https://3v4l.org/OT21N https://github.com/php/php-src/blob/php-7.3.0/ext/date/php_date.c#L1775 I know that passing a parameter to time() is wrong, but I think it could produce a warning and return the value in PHP 7.3 (and 7.4 maybe), since it works fine in 7.2 and is common in C to call it that way. I did not find anything related to deprecation pages, so it may be useful to document this behavior as deprecated in case you decide to keep it as is. Test script: --------------- <?php var_dump(time(null)); Expected result: ---------------- The current Unix timestamp. Actual result: -------------- NULL ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=78509&edit=1

« previous php.bugs (#222625) next »