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

Enhance FILTER_VALIDATE_INT option in filter_var #7608

Closed
takeokunn opened this issue Jul 9, 2022 · 1 comment · Fixed by phpstan/phpstan-src#1499
Closed

Enhance FILTER_VALIDATE_INT option in filter_var #7608

takeokunn opened this issue Jul 9, 2022 · 1 comment · Fixed by phpstan/phpstan-src#1499

Comments

@takeokunn
Copy link

takeokunn commented Jul 9, 2022

Feature request

https://phpstan.org/r/cd41cbe6-b757-4d79-b345-cbc660f00d1e

assertType("1", intval("1"));
assertType("100", intval("100"));
assertType("0", filter_var("0", FILTER_VALIDATE_INT));
assertType("1", filter_var("1", FILTER_VALIDATE_INT));
assertType("100", filter_var("100", FILTER_VALIDATE_INT));
assertType("false", filter_var("abc", FILTER_VALIDATE_INT));
assertType("null", filter_var("abc", FILTER_VALIDATE_INT, FILTER_NULL_ON_FAILURE));

// for octal
assertType("8", filter_var("0o10", FILTER_VALIDATE_INT, FILTER_FLAG_ALLOW_OCTAL));

// for hex
assertType("16", filter_var("0x10", FILTER_VALIDATE_INT, FILTER_FLAG_ALLOW_HEX));

intval can cast ConstantString like1 , but filter_var cannot.

Did PHPStan help you today? Did it make you happy in any way?

PHP is now properly typed and easier to develop with Emacs.

@github-actions
Copy link

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.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 11, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant