You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Invalid return type definition (check example), but all variables checks are present.
Found 1 error: "Method HelloWorld::sayHello() should return int but returns int|null."
strtotime is check and returns a no false value, but still a error is shown that int|flase is returned Method CoffeeBreak::example() should return int but returns int|false.
@EdwinHuijsing This code is incredibly wasteful. You should call strtotime once, save the result into a variable and have the variables guarded and returned. PHPStan won't complain about it either.
Activity
ondrejmirtes commentedon Mar 26, 2024
We already have this working for variables: https://phpstan.org/r/b22a51ff-14f5-483f-871a-10d319052b15
So it's "just" a matter of making this work for general expressions. The relevant piece of code is where we work with ConditionalExpressionHolder.
EdwinHuijsing commentedon Apr 4, 2026
Here is an other example with the same problem
https://phpstan.org/r/68d94256-0329-45bc-b48a-8bfc32fb956e
strtotime is check and returns a no
falsevalue, but still a error is shown that int|flase is returnedMethod CoffeeBreak::example() should return int but returns int|false.ondrejmirtes commentedon Apr 4, 2026
@EdwinHuijsing This code is incredibly wasteful. You should call strtotime once, save the result into a variable and have the variables guarded and returned. PHPStan won't complain about it either.
Fix phpstan/phpstan#10786: Conditional type narrowing for property fe…
Add regression test for conditional holders narrowing coalesce of pro…
Add regression test for conditional holders narrowing coalesce of pro…
Add regression test for conditional holders narrowing coalesce of pro…
Add regression test for conditional holders narrowing coalesce of pro…
Add regression test for conditional holders narrowing coalesce of pro…
Add regression test for conditional holders narrowing coalesce of pro…
Add regression test for conditional holders narrowing coalesce of pro…
Add regression test for conditional holders narrowing coalesce of pro…
Add regression test for conditional holders narrowing coalesce of pro…
Add regression test for conditional holders narrowing coalesce of pro…
Updated PHPStan to commit 5797ebc34202e3436fa22c7d2a6e871370540eb1
github-actions commentedon Aug 29, 2026
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.