diff options
| author | Marcus Boerger <helly@php.net> | 2003-12-19 10:16:08 +0000 |
|---|---|---|
| committer | Marcus Boerger <helly@php.net> | 2003-12-19 10:16:08 +0000 |
| commit | 06aad2d22df114f8304b41897ac4611e2533b66c (patch) | |
| tree | 9da013f71803ccabce13592065d3c3c1c4afb2ae | |
| parent | fbebdb4685e49583b3848fc91121387f03affc48 (diff) | |
| download | php-git-06aad2d22df114f8304b41897ac4611e2533b66c.tar.gz | |
Add test for foreach visibility
| -rwxr-xr-x | tests/classes/visibility_005.phpt | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/tests/classes/visibility_005.phpt b/tests/classes/visibility_005.phpt new file mode 100755 index 0000000000..1b15fb5e5b --- /dev/null +++ b/tests/classes/visibility_005.phpt @@ -0,0 +1,58 @@ +--TEST-- +ZE2 foreach and property visibility +--FILE-- +<?php + +class base +{ + public $a=1; + protected $b=2; + private $c=3; + + function f() + { + foreach($this as $k=>$v) { + echo "$k=>$v\n"; + } + } +} + +class derived extends base +{ +} + +$o = new base; +$o->d = 4; +echo "===base::function===\n"; +$o->f(); +echo "===base,foreach===\n"; +foreach($o as $k=>$v) { + echo "$k=>$v\n"; +} + +$o = new derived; +$o->d = 4; +echo "===derived::function===\n"; +$o->f(); +echo "===derived,foreach===\n"; +foreach($o as $k=>$v) { + echo "$k=>$v\n"; +} + +?> +--EXPECT-- +===base::function=== +a=>1 +b=>2 +c=>3 +d=>4 +===base,foreach=== +a=>1 +d=>4 +===derived::function=== +a=>1 +b=>2 +d=>4 +===derived,foreach=== +a=>1 +d=>4 |
