[php-src] Issue #12567: FILTER_VALIDATE_INT has inconsistent behavior with true/false
| From: | ebrigham1 | Date: | Mon, 30 Oct 2023 13:49:24 +0000 |
| Subject: | [php-src] Issue #12567: FILTER_VALIDATE_INT has inconsistent behavior with true/false | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-245683@lists.php.net to get a copy of this message | ||
Issue: https://github.com/php/php-src/issues/12567
Author: ebrigham1
### Description
The following code:
```php
<?php
declare(strict_types=1);
var_dump(filter_var(true, FILTER_VALIDATE_INT));
var_dump(filter_var(false, FILTER_VALIDATE_INT));
var_dump(filter_var(true, FILTER_VALIDATE_INT, ['flags' => FILTER_NULL_ON_FAILURE]));
var_dump(filter_var(false, FILTER_VALIDATE_INT, ['flags' => FILTER_NULL_ON_FAILURE]));
```
Resulted in this output:
```
int(1)
bool(false)
int(1)
NULL
```
But I expected this output instead:
```
bool(false)
bool(false)
NULL
NULL
```
https://3v4l.org/UuTcm
It might be equally as valid to expect false to produce
int(0), I'm not sure. The
thing that confuses me is that false and true are treated inconsistently.
### PHP Version
PHP 8.2.11
### Operating System
_No response_