Doc #65910 [NEW]: hex2bin returns null rather than false when parameter 1 is not scalar

From: Date: Wed, 16 Oct 2013 05:12:05 +0000
Subject: Doc #65910 [NEW]: hex2bin returns null rather than false when parameter 1 is not scalar
Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-10502@lists.php.net to get a copy of this message
From: lucas at threeamdesign dot com Operating system: PHP version: 5.5Git-2013-10-16 (Git) Package: Scripting Engine problem Bug Type: Documentation Problem Bug description:hex2bin returns null rather than false when parameter 1 is not scalar Description: ------------ The docs say it returns false on failure but it returns null when the first argument is not a string (except objects with __toString() ). The function should be made consistent. People who are aware of this quirk will likely be using a ($val === false || $val === null) test, and people who aren't will likely have only ($val === false). Making it return false wouldn't be perfectly backwards-compatible, but would fix more problems than it causes because failure goes undetected if only the latter test is used. If the quirk must remain for compatibility, at least update the docs. Test script: --------------- <?php var_dump(hex2bin(array())); Expected result: ---------------- Warning: hex2bin() expects parameter 1 to be string, array given in foo.php on line 1 bool(false) Actual result: -------------- Warning: hex2bin() expects parameter 1 to be string, array given in foo.php on line 1 NULL -- Edit bug report at https://bugs.php.net/bug.php?id=65910&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=65910&r=trysnapshot54 Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=65910&r=trysnapshot55 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=65910&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=65910&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=65910&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=65910&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=65910&r=needscript Try newer version: https://bugs.php.net/fix.php?id=65910&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=65910&r=support Expected behavior: https://bugs.php.net/fix.php?id=65910&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=65910&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=65910&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=65910&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=65910&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=65910&r=dst IIS Stability: https://bugs.php.net/fix.php?id=65910&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=65910&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=65910&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=65910&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=65910&r=mysqlcfg

« previous php.doc.bugs (#10502) next »