1--TEST-- 2ZE2 ArrayAccess and exceptions 3--FILE-- 4<?php 5 6class Test implements ArrayAccess 7{ 8 public function offsetExists($offset) { throw new Exception(__METHOD__); return false; } 9 public function offsetGet($offset) { throw new Exception(__METHOD__); return $offset; } 10 public function offsetSet($offset, $data ) { throw new Exception(__METHOD__); } 11 public function offsetUnset($offset) { throw new Exception(__METHOD__); } 12} 13 14$t = new Test; 15 16try 17{ 18 echo isset($t[0]); 19} 20catch(Exception $e) 21{ 22 echo "Caught in " . $e->getMessage() . "()\n"; 23} 24 25try 26{ 27 echo $t[0]; 28} 29catch(Exception $e) 30{ 31 echo "Caught in " . $e->getMessage() . "()\n"; 32} 33 34try 35{ 36 $t[0] = 1; 37} 38catch(Exception $e) 39{ 40 echo "Caught in " . $e->getMessage() . "()\n"; 41} 42 43try 44{ 45 unset($t[0]); 46} 47catch(Exception $e) 48{ 49 echo "Caught in " . $e->getMessage() . "()\n"; 50} 51?> 52===DONE=== 53--EXPECT-- 54Caught in Test::offsetExists() 55Caught in Test::offsetGet() 56Caught in Test::offsetSet() 57Caught in Test::offsetUnset() 58===DONE=== 59