1--TEST-- 2ZE2 foreach and property visibility 3--FILE-- 4<?php 5 6#[AllowDynamicProperties] 7class base 8{ 9 public $a=1; 10 protected $b=2; 11 private $c=3; 12 13 function f() 14 { 15 foreach($this as $k=>$v) { 16 echo "$k=>$v\n"; 17 } 18 } 19} 20 21class derived extends base 22{ 23} 24 25$o = new base; 26$o->d = 4; 27echo "===base::function===\n"; 28$o->f(); 29echo "===base,foreach===\n"; 30foreach($o as $k=>$v) { 31 echo "$k=>$v\n"; 32} 33 34$o = new derived; 35$o->d = 4; 36echo "===derived::function===\n"; 37$o->f(); 38echo "===derived,foreach===\n"; 39foreach($o as $k=>$v) { 40 echo "$k=>$v\n"; 41} 42 43?> 44--EXPECT-- 45===base::function=== 46a=>1 47b=>2 48c=>3 49d=>4 50===base,foreach=== 51a=>1 52d=>4 53===derived::function=== 54a=>1 55b=>2 56c=>3 57d=>4 58===derived,foreach=== 59a=>1 60d=>4 61