-
Notifications
You must be signed in to change notification settings - Fork 550
Fix #13963 with unit tests. #4786
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
base: 2.1.x
Are you sure you want to change the base?
Conversation
|
Hi, I think you're not handling correctly the flag for non-string value I recommend you to add test for You certainly need to do the check you did but after a toString call. |
…_EMPTY_STRING_NULL.
|
Thanks for your feedback! I added some cases and tried to be as precise as I could on type expectations. I feel like it's starting to get too complex when going deeper on union types. I'm not feeling fluent enough with PHPStan's API but I did my best. Again, tell me if I got something wrong here 😉 |
|
I feel like it could be simpler to look for something like with Some existing tests will fail, but I think it's an improvement. to fix. This is something related to (I think) |
|
I think you could try something like https://github.com/phpstan/phpstan-src/compare/2.1.x...VincentLanglet:phpstan-src:fix/filter_var?expand=1 with all your existing tests @niconoe- |
|
Thank you very much for your feedback! I'm giving it a try right now. I'm just curious about this snippet: In the EDIT: nvm, I got it. Aim is to remove any kind of StringType more specific than just a StringType, like an AccessoryNonEmptyStringType for instance, and replace it by a general StringType. This is due to possible sanitations when using flags that will remove unwanted chars from a non-empty-string that could lead to empty strings, and as we don't know, we infer the general StringType. |
|
I tried your proposal and I got 141 errors because of I think this is due to Forcing the input type as a String only matters when having the flag |
It's certainly because of the Maybe you'll have less failure to fix with https://github.com/phpstan/phpstan-src/compare/2.1.x...VincentLanglet:phpstan-src:fix/filter_var_2?expand=1 |
I figured this out too, but I kept the new method I had to fix the remaining failling unit test about |
|
I really don't understand why the unit tests are not passing on PHP 7.4 only and why the actual results differ from the expectations. The behavior of filter_var remained unchanged AFAIK. For the other errors on the pipeline, there are issues about things I did not impact, and memory limit troubles. For both of them, I don't know if I have something to do. |
tests/PHPStan/Analyser/nsrt/filter-var-returns-non-empty-string.php
Outdated
Show resolved
Hide resolved
tests/PHPStan/Analyser/nsrt/filter-var-returns-non-empty-string.php
Outdated
Show resolved
Hide resolved
|
About Mutation testing, I don't get how could I kill both kind of mutations like this: and when Therefore, I don't think such mutation is relevant IMO. And about other failing tests, this is about memory_limit so, I'm not sure I could do something to be fair. |
|
For Maybe some of the other condition can be checked the same way. |
Fixes phpstan/phpstan#13963