We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
DateTime::format('N')
I've a code which iterate on dates and perform some operations using DateTime::format('N') to loop over an array indexed by day in numeric format.
The code looks like something like this:
$from = new DateTimeImmutable('2023-01-30'); for ($offset = 1; $offset <= 14; $offset++) { $value = $from->format('N') + $offset; var_dump($value); if ($value > 7) { } }
The previous code output number from 2 to 15, but phpstan considering that the condition is always false which is wrong.
2
15
Comparison operation ">" between 1|2|3|4|5|6|7 and 7 is always false.
No error should be output.
The text was updated successfully, but these errors were encountered:
It works fine if you cast the result of format https://phpstan.org/r/76eedf26-fcc7-4e07-9f31-2e4821e2df0b
format
There is something wrong with the sum computed, cf https://phpstan.org/r/da56d0cc-d87b-425a-ab37-f48304cbacba
I'll try to fix this with phpstan/phpstan-src#2209
Sorry, something went wrong.
Fixed: phpstan/phpstan-src#2209
Thanks @ondrejmirtes & @VincentLanglet
❤️
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.
Successfully merging a pull request may close this issue.
Bug report
I've a code which iterate on dates and perform some operations using
DateTime::format('N')
to loop over an array indexed by day in numeric format.The code looks like something like this:
The previous code output number from
2
to15
, but phpstan considering that the condition is always false which is wrong.Code snippet that reproduces the problem
Expected output
No error should be output.
The text was updated successfully, but these errors were encountered: