/hphp/test/slow/ext_spl_iterators/bug68128.php

http://github.com/facebook/hiphop-php · PHP · 39 lines · 32 code · 5 blank · 2 comment · 2 complexity · 0dd1aa3e1f0f9249605da922fbbb83e7 MD5 · raw file

  1. <?hh
  2. // https://github.com/php/php-src/pull/865
  3. <<__EntryPoint>>
  4. function main_bug68128() {
  5. $array = new ArrayIterator(varray['a', varray['b', 'c']]);
  6. $regex = new RegexIterator($array, '/Array/');
  7. foreach ($regex as $match) {
  8. var_dump($match); // We should never get here
  9. }
  10. $rArrayIterator = new RecursiveArrayIterator(
  11. varray['test1', varray['tet3', 'test4', 'test5']]
  12. );
  13. $rRegexIterator = new RecursiveRegexIterator(
  14. $rArrayIterator,
  15. '/^(t)est(\d*)/',
  16. RecursiveRegexIterator::ALL_MATCHES,
  17. 0,
  18. PREG_PATTERN_ORDER
  19. );
  20. foreach ($rRegexIterator as $key1 => $value1) {
  21. if ($rRegexIterator->hasChildren()) {
  22. // print all children
  23. echo "Children: ";
  24. foreach ($rRegexIterator->getChildren() as $key => $value) {
  25. print_r($value);
  26. }
  27. echo "\n";
  28. } else {
  29. echo "No children ";
  30. print_r($value1);
  31. echo "\n";
  32. }
  33. }
  34. }