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
 [2019-02-12 10:44 UTC] nikic@php.net
Automatic comment on behalf of daniel@ciochiu.ro
Revision: http://git.php.net/?p=php-src.git;a=commit;h=07877c46e3057bc679766898d50529be812243f3
Log: Fixed bug #75546
 [2020-02-07 06:05 UTC] phpdocbot@php.net
Automatic comment on behalf of cmb
Revision: http://git.php.net/?p=doc/en.git;a=commit;h=9a5f30aaa46a84273c5416141c11160ade281aab
Log: Fix #75546: Clarification for how iterator_apply's $args are passed to the $function
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Mar 28 21:01:27 2024 UTC