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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: miloslav dot hula at gmail dot com
New email:
PHP Version: OS:

 

 [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: Thu May 02 22:01:30 2024 UTC