Bug #49657 [Com]: array_search returns null instead of false
| From: | rodrigovb at gmail dot com | Date: | Sat, 26 Nov 2011 16:11:57 +0000 |
| Subject: | Bug #49657 [Com]: array_search returns null instead of false | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-165512@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=49657&edit=1
ID: 49657
Comment by: rodrigovb at gmail dot com
Reported by: pvenakis at efrontlearning dot net
Summary: array_search returns null instead of false
Status: Bogus
Type: Bug
Package: Unknown/Other Function
Operating System: windows
PHP Version: 5.3.0
Block user comment: N
Private report: N
New Comment:
I'd like to advise you about the impact of this change in the company I work. Based on the last
return value (FALSE) we had 40 php files with some lines checking the result of array_search (===
false). This is a small company with 30 employees (and 40 php files to be changed).
The concern of the owner is if PHP is sustainable enough to keep investing in develop instead of
maintenance due to this changes.
Please write the change log (or point the link with the log) cointaining the real needs of this
ghange.
In my point of view the impact of return value changes of any function could be severe, specially in
bigger companies.
Previous Comments:
------------------------------------------------------------------------
[2009-09-25 07:14:46] pvenakis at efrontlearning dot net
Thanks for the quick response. It's fine that it returns null, but since this changed from 5.2
to 5.3 it would be nice if it were mentioned in the changelog or in the documents.
Best Regards, Periklis
------------------------------------------------------------------------
[2009-09-24 12:17:22] pajoye@php.net
That's expected. Returning NULL on invalid argument(s) is correct.
------------------------------------------------------------------------
[2009-09-24 12:03:47] pvenakis at efrontlearning dot net
Description:
------------
array_search returns false in 5.2.x, null in 5.3.0, when $haystack is not an array
Reproduce code:
---------------
$haystack = false; //Anything not an array
$result = array_search(1, $haystack);
var_dump($result);
Expected result:
----------------
bool(false)
Actual result:
--------------
null
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=49657&edit=1