Doc #70409 [NEW]: FILTER_NULL_ON_FAILURE returns false for null input for FILTER_VALIDATE_BOOLEAN
| From: | thedavidmeister at gmail dot com | Date: | Wed, 02 Sep 2015 12:11:58 +0000 |
| Subject: | Doc #70409 [NEW]: FILTER_NULL_ON_FAILURE returns false for null input for FILTER_VALIDATE_BOOLEAN | ||
| Groups: | php.doc.bugs | ||
| Request: | Send a blank email to doc-bugs+get-12699@lists.php.net to get a copy of this message | ||
From: thedavidmeister at gmail dot com
Operating system: Mac OS X
PHP version: 5.6.13RC1
Package: Documentation problem
Bug Type: Documentation Problem
Bug description:FILTER_NULL_ON_FAILURE returns false for null input for FILTER_VALIDATE_BOOLEAN
Description:
------------
---
From manual page: http://www.php.net/filter.filters.validate
---
Docs say:
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.
Actual, unexpected behaviour:
null will return false when FILTER_NULL_ON_FAILURE is set because
everything is cast to a string before the filter_var() checks are
applied - https://bugs.php.net/bug.php?id=67167&edit=2
Expected behaviour:
Update the documentation to explain that null will return false.
Test script:
---------------
// null is treated as boolean false by filter_var().
filter_var(null, FILTER_VALIDATE_BOOLEAN, FILTER_NULL_ON_FAILURE)
=> false
// null is not actually a boolean.
is_bool(null)
=> false
--
Edit bug report at https://bugs.php.net/bug.php?id=70409&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=70409&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=70409&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=70409&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=70409&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=70409&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=70409&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=70409&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=70409&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=70409&r=support
Expected behavior: https://bugs.php.net/fix.php?id=70409&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=70409&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=70409&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=70409&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=70409&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=70409&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=70409&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=70409&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=70409&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=70409&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=70409&r=mysqlcfg