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, 4 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

--TEST--
Ensure plain userspace superclass does not override special iterator behaviour on child class.
--FILE--
<?php
Class C {}

class D extends C implements Iterator {
  
  private $counter = 2;
  
  public function valid() {
    echo __METHOD__ . "($this->counter)\n";
    return $this->counter;    
  }
  
  public function next() {
    $this->counter--;   
    echo __METHOD__ . "($this->counter)\n";
  }
  
  public function rewind() {
    echo __METHOD__ . "($this->counter)\n";
  }
  
  public function current() {
    echo __METHOD__ . "($this->counter)\n";
  }
  
  public function key() {
    echo __METHOD__ . "($this->counter)\n";
  }
  
}

foreach (new D as $x) {}
?>
--EXPECTF--
D::rewind(2)
D::valid(2)
D::current(2)
D::next(1)
D::valid(1)
D::current(1)
D::next(0)
D::valid(0)

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