php-src/ext/spl/tests/RegexIterator_with_reference_replacement.phpt
Nikita Popov fb346c8f93 Support references in convert_to_*
conver_to_* functions now accept REFERENCE values, which will be
unwrapped before performing the usual conversion. This is consistent
with convert_scalar_to_number and matches the expected behavior in
a couple random use-sites I checked.

Also includes a couple fixes/cleanups elsewhere and two tests for
cases that previously didn't work (though the reference issue existed
all over the place).
2015-06-16 19:55:33 +02:00

20 lines
386 B
PHP

--TEST--
RegexIterator with $replacement being a reference
--FILE--
<?php
$a = new ArrayIterator(array('test1', 'test2', 'test3'));
$i = new RegexIterator($a, '/^(test)(\d+)/', RegexIterator::REPLACE);
$r = '$2:$1';
$i->replacement =& $r;
var_dump(iterator_to_array($i));
?>
--EXPECT--
array(3) {
[0]=>
string(6) "1:test"
[1]=>
string(6) "2:test"
[2]=>
string(6) "3:test"
}