Doc #67038 [NEW]: in_array returns null

From: Date: Mon, 07 Apr 2014 16:02:23 +0000
Subject: Doc #67038 [NEW]: in_array returns null
Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-11120@lists.php.net to get a copy of this message
From: kilbyc at bellsouth dot net Operating system: Windows 7 PHP version: 5.5.11 Package: Documentation problem Bug Type: Documentation Problem Bug description:in_array returns null Description: ------------ http://us1.php.net/in_array is at best misleading, at worst, blatantly wrong. The documentation clearly states that in_array returns bool, true, false. Null is not an acceptable value in that list. Also, the manual does not advise that this function may throw warnings. This has been ignored for a while. https://bugs.php.net/bug.php?id=39788 Test script: --------------- C:\php5.5>php --version PHP 5.5.11 (cli) (built: Apr 2 2014 16:03:05) Copyright (c) 1997-2014 The PHP Group Zend Engine v2.5.0, Copyright (c) 1998-2014 Zend Technologies C:\php5.5>php -r "var_export(in_array('thing', null));" Warning: in_array() expects parameter 2 to be array, null given in Command line NULL Expected result: ---------------- Update the manual to say that in_array issues Warning. And: Either returns NULL if the array is null. OR Fix the function to return false is the array is null. -- Edit bug report at https://bugs.php.net/bug.php?id=67038&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=67038&r=trysnapshot54 Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=67038&r=trysnapshot55 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=67038&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=67038&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=67038&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=67038&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=67038&r=needscript Try newer version: https://bugs.php.net/fix.php?id=67038&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=67038&r=support Expected behavior: https://bugs.php.net/fix.php?id=67038&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=67038&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=67038&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=67038&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=67038&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=67038&r=dst IIS Stability: https://bugs.php.net/fix.php?id=67038&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=67038&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=67038&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=67038&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=67038&r=mysqlcfg

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