php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #65894 array_reduce needs a clarification of how the callback parameters are used
Submitted: 2013-10-14 14:45 UTC Modified: 2017-09-20 12:27 UTC
From: inefedor at gmail dot com Assigned: cmb (profile)
Status: Closed Package: Arrays related
PHP Version: Irrelevant OS:
Private report: No CVE-ID: None
 [2013-10-14 14:45 UTC] inefedor at gmail dot com
Description:
------------
Hi,

In the documentation on array_reduce function ( http://php.net/manual/ru/function.array-reduce.php ) there's callback in the parameters list and it is defined like so "mixed callback ( mixed &$result , mixed $item )".

The $result parameter, for some reason, is being received by reference. But it doesn't make any sense, does it? This variable is destroyed right after zend_call_function call was made.

I know, it might seem like pretty minor bug, but it confused me (and my colleagues) so many times. It may seem like one supposed to result in this variable instead of returning it, so there lays a confusion...


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2013-10-14 14:47 UTC] inefedor at gmail dot com
[typo] ...like one supposed to STORE result in this variable...
 [2013-12-31 20:12 UTC] frozenfire@php.net
-Summary: array_reduce documentation: callback has parameter by reference +Summary: array_reduce needs a clarification of how the callback parameters are used -Status: Open +Status: Verified
 [2013-12-31 20:12 UTC] frozenfire@php.net
The callback definitely needs improved documentation, which could easily be sourced from the notes on the page.
 [2017-09-20 12:27 UTC] cmb@php.net
-Status: Verified +Status: Closed -Assigned To: +Assigned To: cmb
 [2017-09-20 12:27 UTC] cmb@php.net
This issue has been fixed with
<http://svn.php.net/viewvc?view=revision&revision=332884>.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 18 14:01:31 2024 UTC