Doc #75546 [Ver->Csd]: Clarification for how iterator_apply's $args are passed to the $function

From: Date: Sat, 07 Apr 2018 22:07:33 +0000
Subject: Doc #75546 [Ver->Csd]: Clarification for how iterator_apply's $args are passed to the $function
References: 1  Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-15589@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=75546&edit=1

 ID:                 75546
 Updated by:         cmb@php.net
 Reported by:        ycgambo at outlook dot com
 Summary:            Clarification for how iterator_apply's $args are
                     passed to the $function
-Status:             Verified
+Status:             Closed
 Type:               Documentation Problem
 Package:            SPL related
 Operating System:   centos6
 PHP Version:        5.6.32
-Assigned To:        
+Assigned To:        cmb
 Block user comment: N
 Private report:     N



Previous Comments:
------------------------------------------------------------------------
[2018-04-07 22:06:59] cmb@php.net

Automatic comment from SVN on behalf of cmb
Revision: http://svn.php.net/viewvc/?view=revision&revision=344631
Log: Fix #75546: Clarification for how iterator_apply's $args are passed to the $function

This also integrates user note 121897.

------------------------------------------------------------------------
[2017-11-22 06:31:28] ycgambo at outlook dot com

Got it, thanks for reply.

------------------------------------------------------------------------
[2017-11-21 07:17:12] 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-21 06:21:38] 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)


------------------------------------------------------------------------



--
Edit this bug report at https://bugs.php.net/bug.php?id=75546&edit=1


Thread (4 messages)

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