Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

mktime does not return false in PHP 8.0+ #1768

Closed
wants to merge 1 commit into from

Conversation

jaydiablo
Copy link
Contributor

It seems that mktime (https://www.php.net/mktime) will not return false in PHP 8.0+ now. The PHP docs still show that as the signature, but the only way that seems possible to trigger it to return false (in PHP <8) doesn't work anymore because PHP 8 throws a TypeError if you try to pass a string argument (PHP 7 would throw a warning but still return false):

https://3v4l.org/R5JPS

gmmktime appears to function the same way:

https://3v4l.org/7JqeF

PHPStan currently sees mktime as possibly returning false, as seen here: https://phpstan.org/r/8c17702c-d5c9-444f-bcd7-624538d2fa62

It seems that `mktime` (https://www.php.net/mktime) will not return `false` in PHP 8.0+ now. The PHP docs still show that as the signature, but the only way that seems possible to trigger it to return false (in PHP <8) doesn't work anymore because PHP 8 throws a TypeError if you try to pass a string argument (PHP 7 would throw a warning but still return `false`):

https://3v4l.org/R5JPS

`gmmktime` appears to function the same way:

https://3v4l.org/7JqeF

PHPStan currently sees `mktime` as possibly returning false, as seen here: https://phpstan.org/r/8c17702c-d5c9-444f-bcd7-624538d2fa62
@ondrejmirtes
Copy link
Member

This fix will not help because the official stubs that have priority still have int|false: https://github.com/phpstan/php-8-stubs/blob/main/stubs/ext/date/mktime.php#L3

Please open an issue in https://github.com/php/php-src/. Either you'll find out when it returns false, or they'll fix the stub and docs, meaning it will eventually find its way into PHPStan.

Thanks.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants