php-src/ext/spl/tests/bug68128-USE_KEY.phpt
Márcio Almada 4397306b32 fix bug related to #865
In case USE_KEY flag is active, RegexIterator->accept() should keep it's
old behavior which is to accept keys mapping arrays.

This broke after PHP 5.5 but was not noticed due to lack of tests for USE_KEY.
2016-09-22 12:46:19 +02:00

22 lines
491 B
PHP

--TEST--
Bug #68128 - RecursiveRegexIterator raises "Array to string conversion" notice
--FILE--
<?php
$arrayIterator = new ArrayIterator(array('key 1' => 'value 1', 'key 2' => ['value 2']));
$regexIterator = new RegexIterator($arrayIterator, '/^key/', RegexIterator::MATCH, RegexIterator::USE_KEY);
foreach ($regexIterator as $key => $value) {
var_dump($key, $value);
}
?>
--EXPECT--
string(5) "key 1"
string(7) "value 1"
string(5) "key 2"
array(1) {
[0]=>
string(7) "value 2"
}