1--TEST-- 2SplObjectStorage::getHash implementation 3--FILE-- 4<?php 5$s = new SplObjectStorage(); 6$o1 = new Stdclass; 7$o2 = new Stdclass; 8$s[$o1] = "some_value\n"; 9echo $s->offsetGet($o1); 10 11class MySplObjectStorage extends SplObjectStorage { 12 public function getHash($obj) { 13 return 2; 14 } 15} 16 17try { 18 $s1 = new MySplObjectStorage; 19 $s1[$o1] = "foo"; 20} catch(Exception $e) { 21 echo "caught\n"; 22} 23 24class MySplObjectStorage2 extends SplObjectStorage { 25 public function getHash($obj) { 26 throw new Exception("foo"); 27 return "asd"; 28 } 29} 30 31try { 32 $s2 = new MySplObjectStorage2; 33 $s2[$o2] = "foo"; 34} catch(Exception $e) { 35 echo "caught\n"; 36} 37 38class MySplObjectStorage3 extends SplObjectStorage { 39 public function getHash($obj) { 40 return "asd"; 41 } 42} 43 44$s3 = new MySplObjectStorage3; 45$s3[$o1] = $o1; 46var_dump($s3[$o1]); 47$s3[$o2] = $o2; 48 49var_dump($s3[$o1] === $s3[$o2]); 50 51?> 52===DONE=== 53--EXPECT-- 54some_value 55caught 56caught 57object(stdClass)#2 (0) { 58} 59bool(true) 60===DONE=== 61