xref: /PHP-8.4/Zend/tests/gh16371.phpt (revision 1d94fb86)
1--TEST--
2GH-16371: Assertion failure in zend_weakmap_iterator_get_current_key() for invalid iterator
3--FILE--
4<?php
5
6$map = new WeakMap();
7$it = $map->getIterator();
8
9print "# Empty WeakMap\n";
10
11var_dump($it->key());
12var_dump($it->current());
13var_dump($it->valid());
14
15$map = new WeakMap();
16$obj = new stdClass;
17$map[$obj] = 0;
18
19print "# Valid iterator\n";
20
21$it = $map->getIterator();
22var_dump($it->key());
23var_dump($it->current());
24var_dump($it->valid());
25
26print "# End of iterator\n";
27
28$it->next();
29var_dump($it->key());
30var_dump($it->current());
31var_dump($it->valid());
32
33?>
34--EXPECTF--
35# Empty WeakMap
36NULL
37NULL
38bool(false)
39# Valid iterator
40object(stdClass)#%d (0) {
41}
42int(0)
43bool(true)
44# End of iterator
45NULL
46NULL
47bool(false)
48