xref: /PHP-8.1/ext/spl/tests/bug72051.phpt (revision df8119d3)
1--TEST--
2Bug #72051 (The reference in CallbackFilterIterator doesn't work as expected)
3--FILE--
4<?php
5
6$data = [
7    [1,2]
8];
9
10$callbackTest = new CallbackFilterIterator(new ArrayIterator($data), function (&$current) {
11    $current['message'] = 'Test message';
12    return true;
13});
14
15$callbackTest->rewind();
16$data = $callbackTest->current();
17$callbackTest->next();
18print_r($data);
19?>
20--EXPECTF--
21Warning: {closure}(): Argument #1 ($current) must be passed by reference, value given in %s on line %d
22Array
23(
24    [0] => 1
25    [1] => 2
26)
27