Bug #79803 [Nab]: array_key_exists not returning bool
| From: | marekvikartovsky at gmail dot com | Date: | Tue, 07 Jul 2020 10:13:12 +0000 |
| Subject: | Bug #79803 [Nab]: array_key_exists not returning bool | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-227850@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=79803&edit=1
ID: 79803
User updated by: marekvikartovsky at gmail dot com
Reported by: marekvikartovsky at gmail dot com
Summary: array_key_exists not returning bool
Status: Not a bug
Type: Bug
Package: Arrays related
PHP Version: Irrelevant
Assigned To: cmb
Block user comment: N
Private report: N
New Comment:
Thanks for your time, I didnt seen, that there is wrote "This behaviour should not be relied
upon, and care should be taken to ensure that array is an array."
Thank you,
Have a nice day!
Previous Comments:
------------------------------------------------------------------------
[2020-07-07 10:06:09] cmb@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to
report
a bug at http://bugs.php.net/how-to-report.php
<https://www.php.net/manual/en/functions.internal.php>
------------------------------------------------------------------------
[2020-07-07 09:52:00] marekvikartovsky at gmail dot com
Description:
------------
---
From manual page: https://php.net/function.array-key-exists
---
Hello,
if I am calling array_key_exists on NULL by mistake, the function should return bool FALSE, not
NULL. I understand that it shows me a warning, but it also should return bool value as in
documentation.
I tested it on PHP version 7.1.33 and 7.4.7
Test script:
---------------
var_dump(array_key_exists('test', NULL));
Expected result:
----------------
By documentation I am expecting to return a bool value, not NULL or you should return an exception,
not warning.
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=79803&edit=1