Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

False positive error on DateTime constructor for PHP 7.2-7.4 #10863

Closed
integer opened this issue Apr 10, 2024 · 4 comments
Closed

False positive error on DateTime constructor for PHP 7.2-7.4 #10863

integer opened this issue Apr 10, 2024 · 4 comments

Comments

@integer
Copy link
Contributor

integer commented Apr 10, 2024

Bug report

Code $foo = new \DateTime('@'.mktime(12)); generates error Instantiating DateTime with @ produces an error: Unexpected character for PHP 7.2-7.4. But this format is supported for unix timestamps: https://www.php.net/manual/en/datetime.formats.php (see table Localized Notations) and code works https://3v4l.org/Eo67a

Code snippet that reproduces the problem

https://phpstan.org/r/dd0df9da-94ab-4b82-aba7-c936fd9dd724

Expected output

No errors

Did PHPStan help you today? Did it make you happy in any way?

It's quite early after midnight, so not yet today, sorry. But yesterday PHPStan saved me some time. Thanks!

@ondrejmirtes
Copy link
Member

This is the root cause: https://phpstan.org/r/fd2e1bbc-906f-4026-b3b5-341476c61a4d

'@'.mktime(12) should not be resolved to type '@'.

@ondrejmirtes
Copy link
Member

Fixed phpstan/phpstan-src@4a4c739

@integer
Copy link
Contributor Author

integer commented Apr 11, 2024

Thank you very much for quick fix! 🥇

Copy link

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 13, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants