Skip to content

Commit b109c76

Browse files
committed
some ref stuff
1 parent 4d1b0c7 commit b109c76

File tree

2 files changed

+33
-1
lines changed

2 files changed

+33
-1
lines changed

ext/spl/spl_iterators.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3214,7 +3214,7 @@ static const zend_object_iterator_funcs spl_iterator_zip_funcs = {
32143214
NULL, /* get_gc */
32153215
};
32163216

3217-
// TODO: by ref support ??? (what happens now when we have a ref-returning generator?)
3217+
// TODO: by_ref support ???
32183218
PHP_FUNCTION(iterator_zip)
32193219
{
32203220
zval *argv;

ext/spl/tests/iterator_zip.phpt

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,20 @@ foreach (iterator_zip(gen_with_key(0), $a) as $key => $val) {
4444
unset($key);
4545
}
4646

47+
function &gen_reference() {
48+
$value = 3;
49+
50+
while ($value > 0) {
51+
yield $value;
52+
}
53+
}
54+
55+
foreach (iterator_zip(gen_reference(), gen_reference()) as $vals) {
56+
var_dump($vals);
57+
--$vals[0];
58+
--$vals[1];
59+
}
60+
4761
?>
4862
--EXPECT--
4963
int(1)
@@ -95,3 +109,21 @@ KEYS: b, y
95109
VALS: 1, 2
96110
KEYS: 3, 3
97111
VALS: 2, 3
112+
array(2) {
113+
[0]=>
114+
&int(3)
115+
[1]=>
116+
&int(3)
117+
}
118+
array(2) {
119+
[0]=>
120+
&int(2)
121+
[1]=>
122+
&int(2)
123+
}
124+
array(2) {
125+
[0]=>
126+
&int(1)
127+
[1]=>
128+
&int(1)
129+
}

0 commit comments

Comments
 (0)