php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #70500 array_keys() returns NULL
Submitted: 2015-09-15 10:03 UTC Modified: 2015-09-15 11:57 UTC
From: miloslav dot hula at gmail dot com Assigned:
Status: Closed Package: Documentation problem
PHP Version: 7.0.0RC2 OS:
Private report: No CVE-ID: None
 [2015-09-15 10:03 UTC] miloslav dot hula at gmail dot com
Description:
------------
The array_keys() returns NULL when called with NULL instead of array.

Test script:
---------------
<?php

var_dump(array_keys(NULL));


Expected result:
----------------
array(0) {
}

Actual result:
--------------
NULL

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2015-09-15 10:07 UTC] miloslav dot hula at gmail dot com
Generally returns NULL on anything else than array.
 [2015-09-15 11:51 UTC] requinix@php.net
-Status: Open +Status: Wont fix
 [2015-09-15 11:51 UTC] requinix@php.net
Standard practice for internal functions is to return NULL when passed arguments of the wrong type. Documenting this on every single function page would be crazy so it's mentioned on the internal functions page instead.
http://php.net/functions.internal
 [2015-09-15 11:57 UTC] miloslav dot hula at gmail dot com
-Status: Wont fix +Status: Closed
 [2015-09-15 11:57 UTC] miloslav dot hula at gmail dot com
From doc:
> In this case it will likely return NULL but this is just a convention, and cannot be relied upon.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 19 15:01:28 2024 UTC