summaryrefslogtreecommitdiff
path: root/Zend/tests/bug32674.phpt
blob: f932517d9b7b505080097272c1b1a8ad65690b93 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
--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 happened');

    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