1--TEST--
2DOMDocument node list length cache invalidation
3--EXTENSIONS--
4dom
5--FILE--
6<?php
7
8$doc = new DOMDocument();
9$doc->loadHTML('<p>hello</p><p>world</p><p>!</p>');
10
11$elements = $doc->getElementsByTagName('p');
12$item = $elements->item(0); // Activate item cache
13var_dump($elements->length); // Length not cached yet, should still compute
14$item->remove();
15// Now element 0 means "world", and 1 means "!"
16unset($item);
17var_dump($elements->length);
18$item = $elements->item(1);
19var_dump($item->textContent);
20$item = $elements->item(1);
21var_dump($item->textContent);
22$item = $elements->item(0);
23var_dump($item->textContent);
24$item = $elements->item(1);
25var_dump($item->textContent);
26
27?>
28--EXPECT--
29int(3)
30int(2)
31string(1) "!"
32string(1) "!"
33string(5) "world"
34string(1) "!"
35