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