phpstan: Wrong return type in ternary operator
Bug report
Stan seems can not derive correct type if ternary operator used like this:
$test->test() ? $test->test()->format('d') : null
Code snippet that reproduces the problem
https://phpstan.org/r/ff44c8c8-06ca-470a-a716-ebd334aee215
Expected output
Stan should not complain about type.
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Comments: 22 (20 by maintainers)
Links to this issue
- Update dependency phpstan/phpstan to v1 (!94) · Merge requests · nano8 / core / httpcode · GitLab
- Update dependency phpstan/phpstan to v1 (!121) · Merge requests · nano8 / core / display · GitLab
- Update dependency phpstan/phpstan to v1 (!85) · Merge requests · nano8 / core / security · GitLab
- Update dependency phpstan/phpstan to v1 (!109) · Merge requests · nano8 / core / request · GitLab
- Update dependency phpstan/phpstan to v1 (!92) · Merge requests · nano8 / core / config · GitLab
- Update dependency phpstan/phpstan to v1 (!105) · Merge requests · nano8 / core / validate · GitLab
Yeah, I plan to do something about it, stay tuned.
But please stop discussing this in this issue, it’s unrelated.
json_decodereturn type ismixedso it can return anything, but it also might return the correct thing. That’s why it doesn’t complain. And it’s unrelated to this issue.