1--TEST--
2Entity references with stale entity declaration 02
3--EXTENSIONS--
4dom
5--FILE--
6<?php
7
8$dom = new DOMDocument;
9$dom->loadXML(<<<XML
10<!DOCTYPE foo [
11<!ENTITY foo1 "bar1">
12<!ENTITY foo2 "bar2">
13<!ENTITY foo3 "bar3">
14]>
15<foo>&foo1;</foo>
16XML);
17
18$ref = $dom->documentElement->firstChild;
19$decl = $ref->firstChild;
20
21$nodes = $ref->childNodes;
22$iter = $nodes->getIterator();
23$iter->next();
24$dom->removeChild($dom->doctype);
25unset($decl);
26
27try {
28    var_dump($iter->current()->publicId);
29} catch (Error $e) {
30    echo $e->getMessage(), "\n";
31}
32
33?>
34--EXPECT--
35NULL
36