Annotation of embedaddon/php/ext/spl/tests/bug38618.phpt, revision 1.1

1.1     ! misho       1: --TEST--
        !             2: Bug #38618 (RecursiveArrayIterator::hasChildren() follows objects)
        !             3: --FILE--
        !             4: <?php # vim:ft=php
        !             5: 
        !             6: class 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: 
        !            21: class 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: 
        !            36: function 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: 
        !            56: test_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: 
        !            69: test_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: 
        !            82: test_array($array, 'Protected Property');
        !            83: 
        !            84: test_array($array, 'Public Property New', RecursiveArrayIterator::CHILD_ARRAYS_ONLY);
        !            85: test_array($array, 'Protected Property New', RecursiveArrayIterator::CHILD_ARRAYS_ONLY);
        !            86: ?>
        !            87: ===DONE===
        !            88: <?php exit(0); ?>
        !            89: ?>
        !            90: ===DONE===
        !            91: --EXPECTF--
        !            92: ===Default with array===
        !            93: 1 => apple
        !            94: 1 => grape
        !            95: ===Public Property===
        !            96: title => apple
        !            97: title => grape
        !            98: ===Protected Property===
        !            99: ===Public Property New===
        !           100: 1 => apple
        !           101: 1 => grape
        !           102: ===Protected Property New===
        !           103: 1 => apple
        !           104: 1 => grape
        !           105: ===DONE===

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>