Doc #69735 [Com]: array_splice() return value could be confusing

From: Date: Fri, 18 Dec 2015 21:13:54 +0000
Subject: Doc #69735 [Com]: array_splice() return value could be confusing
References: 1  Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-12980@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=69735&edit=1 ID: 69735 Comment by: tpunt@php.net Reported by: chealer at gmail dot com Summary: array_splice() return value could be confusing Status: Assigned Type: Documentation Problem Package: Documentation problem PHP Version: Irrelevant Assigned To: tpunt Block user comment: N Private report: N New Comment: It's a minor edit, but I do agree that saying that "the array" implies the original array, whereas "an array" would imply a new array. Resolved with commit: https://svn.php.net/viewvc?view=revision&revision=338309 Previous Comments: ------------------------------------------------------------------------ [2015-12-18 21:12:13] tpunt@php.net Automatic comment from SVN on behalf of tpunt Revision: http://svn.php.net/viewvc/?view=revision&revision=338309 Log: Resolves doc bug #69735 ------------------------------------------------------------------------ [2015-05-31 19:02:00] chealer at gmail dot com Note that while I do think my suggestion might have sufficed to prevent my mistake, I did not mean to imply that explicitly warning that the array returned does not contain the remaining elements was superfluous. I find the behavior somewhat unintuitive, and that seems to be confirmed by the most voted comment ( http://php.net/function.array-splice#106244 ). A greater protection against misunderstanding may be warranted. ------------------------------------------------------------------------ [2015-05-31 18:50:44] chealer at gmail dot com Description: ------------ I spent 10 minutes debugging why $foo = array_splice($foo, 0, 1); would remove the wrong element from a 2-element array. I then realized I has misread the documentation: --- From manual page: http://www.php.net/function.array-splice --- Return Values ¶ Returns the array consisting of the extracted elements. ---- I had hastily read the above as "Returns the array without the extracted elements." There is no way I could have been confused had I carefully read the whole sentence, but the sentence is still technically incorrect, since several arrays can consist of the extracted elements. I might not have misunderstood had the sentence read: Returns an array consisting of the extracted elements. Otherwise, the documentation could specify which array consisting of the extracted elements is returned. ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=69735&edit=1

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