php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #61798 Insufficient description of result value, in documentation.
Submitted: 2012-04-21 12:05 UTC Modified: 2012-04-21 16:04 UTC
From: ilias_email at yahoo dot gr Assigned:
Status: Not a bug Package: Documentation problem
PHP Version: Irrelevant OS: Irrelevant
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 you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: ilias_email at yahoo dot gr
New email:
PHP Version: OS:

 

 [2012-04-21 12:05 UTC] ilias_email at yahoo dot gr
Description:
------------
---
From manual page: http://www.php.net/function.array-reverse#refsect1-function.array-reverse-returnvalues
---
Hello. I think that something is missing from the documentation.

You said that "Returns the reversed array."

..but if in the $array parameter I didn't give an array, what it will return?
I think that this must be mentioned in the documentation.

Now, I have to test it manually in order to see the behavior.

Test script:
---------------
$arr = my_function(); // This, may return an array, but may return bool false.

$arr = array_reverse($arr, true); // What will happen if "$arr === false" ?

/* * * * * * * * * * * * * * * * * * * * * *
 * Just to be sure, I have to write this:  */

$arr = my_function();

if($arr !== false) $arr = array_reverse($arr, true);


Expected result:
----------------
echo array_reverse(false);

/*

Expected Result === false

or

WARNING?

*/

Actual result:
--------------
It is not clear in the documentation

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2012-04-21 15:39 UTC] salathe@php.net
-Status: Open +Status: Not a bug
 [2012-04-21 15:39 UTC] salathe@php.net
By convention we do not document return values when given unexpected input.  We do document [1] that many internal functions 
return NULL in this case (they often also give an E_WARNING message).  

It is good practice to be checking the type of a variable if it may be inappropriate for a particular function call.

[1] http://php.net/manual/en/functions.internal.php
 [2012-04-21 16:04 UTC] ilias_email at yahoo dot gr
Thank you for the quick reply.

For the function "count" there is a very detailed description for the returned value.

http://gr.php.net/manual/en/function.count.php


I just noticed that the count input variable is "mixed" type.
Maybe this is the difference.

Btw, if I call the array_reverse() with boolean input, I get this message:

Warning: array_reverse() expects parameter 1 to be array, boolean given in C:\inetpub\wwwroot\test\array_reverse.php on line 3

-------

You can lock this topic.
I don't need anything else.
Again, thank you for your time.

ilias
 
PHP Copyright © 2001-2026 The PHP Group
All rights reserved.
Last updated: Thu Oct 08 13:00:02 2026 UTC