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
declare assert-if-true for filesystem functions #1993
base: 1.9.x
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Two problems here:
chdir($dir) ? 'foo' : 'bar'
- in the else branch$dir
will be considered''
- If you pass
non-empty-string
tochdir(...)
, you'll get "always true" error.
Both can be solved with =non-empty-string
. See: phpstan/phpstan#8348 + phpstan/phpstan#8351
49564b7
to
766c8d9
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To make sure that =
actually fixes these problems, you should have tested the else
condition types and also put a test about this in ImpossibleCheckTypeFunctionCallRule (before adding the =
everywhere). Please verify this was originally a problem and that it's fixed after the change. I'm sure you can find the previous version in your reflog :) It's e117fce or 49564b7.
good point.
|
closes phpstan/phpstan#6788