-
-
Notifications
You must be signed in to change notification settings - Fork 947
Enhance FILTER_VALIDATE_INT option in filter_var #7608
Copy link
Copy link
Closed
phpstan/phpstan-src
#1499Description
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.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels