Skip to content
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

Check filter_input* type param type #2271

Merged
merged 1 commit into from
Apr 13, 2023

Conversation

herndlm
Copy link
Contributor

@herndlm herndlm commented Mar 4, 2023

Specifying invalid ints there fails with a fatal error since PHP 8, see https://3v4l.org/2QvBP and https://3v4l.org/EP3T8
It would also be wrong on pre PHP 8 but there's no fatal error there at least.

This is the easiest I could come up with to check this, but it feels a bit weird. Any better ideas?

See also https://www.php.net/manual/en/function.filter-input.php and https://www.php.net/manual/en/function.filter-input-array.php
The 2 failing tests seem unrelated.

Some special handling based on PHP version could also be additionally built into e.g. #2010 (which can be merged I believe ;))

@ondrejmirtes
Copy link
Member

Although it makes the code safer, it can be quite annoying to require users to write a more specific PHPDoc type in their @param.

We need to figure out a way how to do these changes only in bleedingEdge. Then we'd also be albe to merge this #2163 and this #2217.

@staabm
Copy link
Contributor

staabm commented Mar 8, 2023

We need to figure out a way how to do these changes only in bleedingEdge

what do you think about enabling these errors/use more precise signatures only when bleedingEdge and strict-rules are enabled?

@herndlm
Copy link
Contributor Author

herndlm commented Mar 8, 2023

makes sense, thx for the inputs! I thought here it might be okay, because nobody ever should call these functions differently. I think it's a bit different compared to the linked PRs, but I get the general problem and point :)

resources/functionMap_php80delta.php Outdated Show resolved Hide resolved
@herndlm herndlm marked this pull request as ready for review April 13, 2023 15:15
@phpstan-bot
Copy link
Collaborator

This pull request has been marked as ready for review.

@ondrejmirtes ondrejmirtes merged commit 706ba08 into phpstan:1.10.x Apr 13, 2023
377 of 378 checks passed
@ondrejmirtes
Copy link
Member

Thank you!

@herndlm herndlm deleted the filter-input-param-type branch April 13, 2023 19:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants