php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #75546 Clarification for how iterator_apply's $args are passed to the $function
Submitted: 2017-11-21 06:21 UTC Modified: 2018-04-07 22:07 UTC
Votes:1
Avg. Score:4.0 ± 0.0
Reproduced:0 of 0 (0.0%)
From: ycgambo at outlook dot com Assigned: cmb (profile)
Status: Closed Package: SPL related
PHP Version: 5.6.32 OS: centos6
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: ycgambo at outlook dot com
New email:
PHP Version: OS:

 

 [2017-11-21 06:21 UTC] ycgambo at outlook dot com
Description:
------------
---
From manual page: http://www.php.net/function.iterator-apply
---

the 3rd parameter `args` of iterator-apply doesn't passed to callback as an array.

Test script:
---------------
<?php
$ai = new ArrayIterator(range(0, 2));

iterator_apply($ai, function($args) {
    var_dump($args);
    return true;
}, array(1, 2));


Expected result:
----------------
array(2) {
  [0] =>
  int(1)
  [1] =>
  int(2)
}
array(2) {
  [0] =>
  int(1)
  [1] =>
  int(2)
}
array(2) {
  [0] =>
  int(1)
  [1] =>
  int(2)
}

Actual result:
--------------
int(1)
int(1)
int(1)

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2017-11-21 07:17 UTC] requinix@php.net
-Summary: iterator-apply parameter passed unexpected +Summary: Clarification for how iterator_apply's $args are passed to the $function -Status: Open +Status: Verified
 [2017-11-21 07:17 UTC] requinix@php.net
$args is an array and each of its elements are passed to the callback as separate arguments.
https://3v4l.org/6Qrnk
 [2017-11-22 06:31 UTC] ycgambo at outlook dot com
Got it, thanks for reply.
 [2018-04-07 22:06 UTC] cmb@php.net
Automatic comment from SVN on behalf of cmb
Revision: http://svn.php.net/viewvc/?view=revision&amp;revision=344631
Log: Fix #75546: Clarification for how iterator_apply's $args are passed to the $function

This also integrates user note 121897.
 [2018-04-07 22:07 UTC] cmb@php.net
-Status: Verified +Status: Closed -Assigned To: +Assigned To: cmb
 
PHP Copyright © 2001-2018 The PHP Group
All rights reserved.
Last updated: Fri Jul 20 22:01:25 2018 UTC