Bug #39788 [Nab]: in_array don't return false or true
| From: | requinix@php.net | Date: | Mon, 07 Apr 2014 17:00:28 +0000 |
| Subject: | Bug #39788 [Nab]: in_array don't return false or true | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-185136@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=39788&edit=1
ID: 39788
Updated by: requinix@php.net
Reported by: roberto at spadim dot com dot br
Summary: in_array don't return false or true
Status: Not a bug
Type: Bug
Package: Arrays related
Operating System: ALL
PHP Version: 5.2.0
-Block user comment: No
+Block user comment: Yes
Private report: N
New Comment:
Thanks for bringing this ticket back up again after almost 7.5 years.
It is well established that internal functions may return NULL when you pass invalid or not enough
arguments. It's stated on the manual page for internal functions. Making that note again on
every single function's documentation page is redundant.
Previous Comments:
------------------------------------------------------------------------
[2014-04-07 15:47:47] kilbyc at bellsouth dot net
I am not entirely sure how this can be filed as "Not a Bug"
Regardless of the emission of the Warning, the documentation clearly states that in_array returns
bool, true, false. Null is not an acceptable value in that list.
One of the two things needs to be fixed. Either update the manual to say that in_array throws a
Warning, and returns NULL if the array is null.
OR
Fix the function to return false is the array is null.
------------------------------------------------------------------------
[2006-12-10 14:09:03] tony2001@php.net
PHP Warning: Wrong parameter count for in_array() in /tmp/6.php on line 25
Warning: Wrong parameter count for in_array() in /tmp/6.php on line 25
NULL
------------------------------------------------------------------------
[2006-12-10 13:26:10] roberto at spadim dot com dot br
Description:
------------
RETURN NULL?!?! see documentation
http://br.php.net/manual/pt_BR/function.in-array.php
just can return TRUE or FALSE! NULL isn't allowed!
see that i'm using 4 parameters and no error was showed
Reproduce code:
---------------
<?php
$images=array(
"cabec0" => "cabec0", "cabec1" => "cabec1",
"cabec2" => "cabec2", "cabec3" => "cabec3",
"cabec4" => "cabec4",
"login0" => "login0", "login1" => "login1",
"login2" => "login2", "login3" => "login3",
"login4" => "login4",
"messenger0" => "messenger0", "messenger1" =>
"messenger1",
"messenger2" => "messenger2", "messenger3" =>
"messenger3",
"messenger4" => "messenger4",
"file_explorer0" => "explorer0","file_explorer1" =>
"explorer1",
"file_explorer2" => "explorer2","file_explorer3" =>
"explorer3",
"file_explorer4" => "explorer4",
"yellow"=>"yellow","red"=>"red",
"gray"=>"gray","blue"=>"blue","green"=>"green",
"logo" => "logo.png", "smm" => "smm.gif"
);
$image='rodape';
var_dump(in_array($image,'logo','rodape','smm'));
print_r($images);
?>
Expected result:
----------------
FALSE
Actual result:
--------------
NULL
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=39788&edit=1