Annotation of embedaddon/php/tests/lang/foreachLoopObjects.004.phpt, revision 1.1.1.1

1.1       misho       1: --TEST--
                      2: Foreach loop tests - Removing the current element from an iterated object.
                      3: --FILE--
                      4: <?php
                      5: 
                      6: class C {
                      7:        public $a = "Original a";
                      8:        public $b = "Original b";
                      9:        public $c = "Original c";
                     10:        public $d = "Original d";
                     11:        public $e = "Original e";
                     12: }
                     13: 
                     14: echo "\nRemoving the current element from an iterated object.\n";
                     15: $obj = new C;
                     16: $count=0;
                     17: foreach ($obj as $v) {
                     18:        if ($v==$obj->b) {
                     19:                unset($obj->b); 
                     20:        }
                     21:        var_dump($v);
                     22:        if (++$count>10) {
                     23:                echo "Loop detected.\n";
                     24:                break;
                     25:        }       
                     26: }
                     27: var_dump($obj);
                     28: 
                     29: 
                     30: ?>
                     31: ===DONE===
                     32: --EXPECTF--
                     33: Removing the current element from an iterated object.
                     34: string(10) "Original a"
                     35: string(10) "Original b"
                     36: 
                     37: Notice: Undefined property: C::$b in %s on line %d
                     38: string(10) "Original c"
                     39: 
                     40: Notice: Undefined property: C::$b in %s on line %d
                     41: string(10) "Original d"
                     42: 
                     43: Notice: Undefined property: C::$b in %s on line %d
                     44: string(10) "Original e"
                     45: object(C)#%d (4) {
                     46:   ["a"]=>
                     47:   string(10) "Original a"
                     48:   ["c"]=>
                     49:   string(10) "Original c"
                     50:   ["d"]=>
                     51:   string(10) "Original d"
                     52:   ["e"]=>
                     53:   string(10) "Original e"
                     54: }
                     55: ===DONE===

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