1--TEST-- 2Bug #38618 (RecursiveArrayIterator::hasChildren() follows objects) 3--FILE-- 4<?php 5 6class FruitPublic 7{ 8 public $title; 9 10 public function __construct($title) 11 { 12 $this->title = $title; 13 } 14 15 public function __toString() 16 { 17 return $this->title; 18 } 19} 20 21class FruitProtected 22{ 23 protected $title; 24 25 public function __construct($title) 26 { 27 $this->title = $title; 28 } 29 30 public function __toString() 31 { 32 return $this->title; 33 } 34} 35 36function test_array($array, $which, $flags = 0) 37{ 38 echo "===$which===\n"; 39 $it = new RecursiveArrayIterator($array, $flags); 40 foreach (new RecursiveIteratorIterator($it) as $k => $fruit) { 41 echo $k , ' => ', $fruit, "\n"; 42 } 43} 44 45$array = array( 46 1 => array( 47 1 => array( 48 1 => 'apple', 49 ), 50 2 => array( 51 1 => 'grape', 52 ), 53 ), 54); 55 56test_array($array, 'Default with array'); 57 58$array = array( 59 1 => array( 60 1 => array( 61 1 => new FruitPublic('apple'), 62 ), 63 2 => array( 64 1 => new FruitPublic('grape'), 65 ), 66 ), 67); 68 69test_array($array, 'Public Property'); 70 71$array = array( 72 1 => array( 73 1 => array( 74 1 => new FruitProtected('apple'), 75 ), 76 2 => array( 77 1 => new FruitProtected('grape'), 78 ), 79 ), 80); 81 82test_array($array, 'Protected Property'); 83 84test_array($array, 'Public Property New', RecursiveArrayIterator::CHILD_ARRAYS_ONLY); 85test_array($array, 'Protected Property New', RecursiveArrayIterator::CHILD_ARRAYS_ONLY); 86?> 87--EXPECT-- 88===Default with array=== 891 => apple 901 => grape 91===Public Property=== 92title => apple 93title => grape 94===Protected Property=== 95===Public Property New=== 961 => apple 971 => grape 98===Protected Property New=== 991 => apple 1001 => grape 101