Doc #61798 [Opn->Nab]: Insufficient description of result value, in documentation.
| From: | salathe@php.net | Date: | Sat, 21 Apr 2012 15:39:14 +0000 |
| Subject: | Doc #61798 [Opn->Nab]: Insufficient description of result value, in documentation. | ||
| References: | 1 | Groups: | php.doc.bugs |
| Request: | Send a blank email to doc-bugs+get-8282@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=61798&edit=1
ID: 61798
Updated by: salathe@php.net
Reported by: ilias_email at yahoo dot gr
Summary: Insufficient description of result value, in
documentation.
-Status: Open
+Status: Not a bug
Type: Documentation Problem
Package: Documentation problem
Operating System: Irrelevant
PHP Version: Irrelevant
Block user comment: N
Private report: N
New Comment:
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
Previous Comments:
------------------------------------------------------------------------
[2012-04-21 12:05:20] 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
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=61798&edit=1