File:  [ELWIX - Embedded LightWeight unIX -] / embedaddon / php / tests / classes / iterators_008.phpt
Revision 1.1.1.1 (vendor branch): download - view: text, annotated - select for diffs - revision graph
Tue Feb 21 23:48:06 2012 UTC (12 years, 6 months ago) by misho
Branches: php, MAIN
CVS tags: v5_4_3elwix, v5_4_29p0, v5_4_29, v5_4_20p0, v5_4_20, v5_4_17p0, v5_4_17, v5_3_10, HEAD
php

    1: --TEST--
    2: Ensure plain userspace superclass does not override special iterator behaviour on child class.
    3: --FILE--
    4: <?php
    5: Class C {}
    6: 
    7: class D extends C implements Iterator {
    8:   
    9:   private $counter = 2;
   10:   
   11:   public function valid() {
   12:     echo __METHOD__ . "($this->counter)\n";
   13:     return $this->counter;    
   14:   }
   15:   
   16:   public function next() {
   17:     $this->counter--;   
   18:     echo __METHOD__ . "($this->counter)\n";
   19:   }
   20:   
   21:   public function rewind() {
   22:     echo __METHOD__ . "($this->counter)\n";
   23:   }
   24:   
   25:   public function current() {
   26:     echo __METHOD__ . "($this->counter)\n";
   27:   }
   28:   
   29:   public function key() {
   30:     echo __METHOD__ . "($this->counter)\n";
   31:   }
   32:   
   33: }
   34: 
   35: foreach (new D as $x) {}
   36: ?>
   37: --EXPECTF--
   38: D::rewind(2)
   39: D::valid(2)
   40: D::current(2)
   41: D::next(1)
   42: D::valid(1)
   43: D::current(1)
   44: D::next(0)
   45: D::valid(0)

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