xref: /PHP-8.3/ext/spl/tests/bug67582.phpt (revision 6d805ed2)
1--TEST--
2Bug #67582: Cloned SplObjectStorage with overwritten getHash fails offsetExists()
3--FILE--
4<?php
5
6class MyObjectStorage extends SplObjectStorage {
7    // Overwrite getHash() with just some (working) test-method
8    public function getHash($object): string { return get_class($object); }
9}
10
11class TestObject {}
12
13$list = new MyObjectStorage();
14$list->attach(new TestObject());
15
16foreach($list as $x) var_dump($list->offsetExists($x));
17
18$list2 = clone $list;
19foreach($list2 as $x) var_dump($list2->offsetExists($x));
20
21?>
22--EXPECT--
23bool(true)
24bool(true)
25