php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #50687 array_reverse return values missing NULL
Submitted: 2010-01-07 17:39 UTC Modified: 2010-01-13 12:37 UTC
From: hanskrentel at yahoo dot de Assigned:
Status: Not a bug Package: Documentation problem
PHP Version: 5.2.8 OS: win
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: hanskrentel at yahoo dot de
New email:
PHP Version: OS:

 

 [2010-01-07 17:39 UTC] hanskrentel at yahoo dot de
Description:
------------
array_reverse has array as documented return type. while running
var_dump(array_reverse(NULL)); it reported to me NULL. I
think some documentation is missing here.

Reproduce code:
---------------
---
From manual page: function.array-reverse#Return Values
---


Expected result:
----------------
array (Not that I personally would expect that, but the documentation).

Actual result:
--------------
null

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2010-01-07 23:02 UTC] kalle@php.net
According to the sources, then the only time array_reverse() would return NULL would also emit an E_WARNING in the 5.2 branch:

2696 	if (Z_TYPE_PP(input) != IS_ARRAY) {
 
2697 		php_error_docref(NULL TSRMLS_CC, E_WARNING, "The argument should be an array");
 
2698 		return;
 
2699 	}
 [2010-01-10 02:31 UTC] hanskrentel at yahoo dot de
Sorry for not mentioning that it does a warning as well:

So it does return NULL and it does a warning.

According to the documentation it does return array only, not NULL.
 [2010-01-11 06:35 UTC] kalle@php.net
If you pass an unexpected type to some functions in 5.2.x, they will emit a warning and return "undefined". 5.3.x is more strict and won't silently convert incompatible types, and also returns "undefined". So this report is still bogus.
 [2010-01-13 12:37 UTC] hanskrentel at yahoo dot de
Thank you for clarification, I did not read the NULL as undefined. But what you write makes pretty much sense, I will adopt for other function return values as well.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon May 20 19:01:33 2024 UTC