Doc #61798 [Nab]: Insufficient description of result value, in documentation.

From: Date: Sat, 21 Apr 2012 16:04:20 +0000
Subject: Doc #61798 [Nab]: Insufficient description of result value, in documentation.
References: 1  Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-8283@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 User updated by: ilias_email at yahoo dot gr Reported by: ilias_email at yahoo dot gr Summary: Insufficient description of result value, in documentation. 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: 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 Previous Comments: ------------------------------------------------------------------------ [2012-04-21 15:39:14] 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 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

« previous php.doc.bugs (#8283) next »