From f31df5693ec68b7dfa0b738f0356c382816f2abe Mon Sep 17 00:00:00 2001 From: Marcus Boerger Date: Tue, 8 Jul 2003 23:25:18 +0000 Subject: [PATCH] Currently we're presented all properties with foreach() --- ext/spl/tests/foreach_non_spl.phpt | 61 ++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100755 ext/spl/tests/foreach_non_spl.phpt diff --git a/ext/spl/tests/foreach_non_spl.phpt b/ext/spl/tests/foreach_non_spl.phpt new file mode 100755 index 0000000000..bb2eed1c1e --- /dev/null +++ b/ext/spl/tests/foreach_non_spl.phpt @@ -0,0 +1,61 @@ +--TEST-- +SPL: foreach non spl classes +--SKIPIF-- + +--FILE-- +num; + } + function next() { + echo __METHOD__ . "\n"; + $this->num++; + } + function has_more() { + echo __METHOD__ . "\n"; + return $this->num < $this->max; + } + function key() { + echo __METHOD__ . "\n"; + switch($this->num) { + case 0: return "1st"; + case 1: return "2nd"; + case 2: return "3rd"; + default: return "???"; + } + } +} + +$obj = new c2(); + +foreach($obj as $v => $w) { + echo "object:$v=>$w\n"; +} + +print "Done\n"; +?> +--EXPECTF-- +1st try +2nd try +object:max=>3 +object:num=>0 +Done -- 2.40.0