[php-src] Issue #11390: FILTER_VALIDATE_BOOLEAN returns wrong result for null

From: Date: Wed, 07 Jun 2023 11:13:56 +0000
Subject: [php-src] Issue #11390: FILTER_VALIDATE_BOOLEAN returns wrong result for null
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-244615@lists.php.net to get a copy of this message
Issue: https://github.com/php/php-src/issues/11390 Author: thomassb ### Description The following code: ```php <?php var_dump(filter_var(null, FILTER_VALIDATE_BOOLEAN, FILTER_NULL_ON_FAILURE)); ``` Resulted in this output: ``` bool(false) ``` But I expected this output instead: ``` null ``` Documentation states > Returns true for "1", "true", "on" and "yes". Returns > false otherwise. If FILTER_NULL_ON_FAILURE is set, false is returned only for "0", "false", "off", "no", and "", and null is returned for all non-boolean values. So the expected result should return null as null is not '0', 'false', 'off' or ''. ### PHP Version php 8.0.28 ### Operating System Debian

« previous php.bugs (#244615) next »