File:  [ELWIX - Embedded LightWeight unIX -] / embedaddon / php / Zend / tests / bug32674.phpt
Revision 1.1.1.1 (vendor branch): download - view: text, annotated - select for diffs - revision graph
Tue Feb 21 23:47:52 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--
Bug #32674 (exception in iterator causes crash)
--FILE--
<?php
class collection implements Iterator {

  private $_elements = array();

  public function __construct() {
  }

  public function rewind() {
    reset($this->_elements);
  }

  public function count() {
    return count($this->_elements);
  }

  public function current() {
    $element = current($this->_elements);
    return $element;
  }

  public function next() {
    $element = next($this->_elements);
    return $element;
  }

  public function key() {
    $this->_fillCollection();
    $element = key($this->_elements);
    return $element;
  }

  public function valid() {
    throw new Exception('shit happend');

    return ($this->current() !== false);
  }
}

class class2 {
  public $dummy;
}

$obj = new class2();
$col = new collection();

try {
	foreach($col as $co) {
  	//irrelevant
	}
	echo 'shouldn`t get here';
	//$dummy = 'this will not crash'; 
	$obj->dummy = 'this will crash';
} catch (Exception $e) {
	echo "ok\n";
}
?>
--EXPECT--
ok

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