From c410fb889580a55ee09aa728a0ad4770df40e127 Mon Sep 17 00:00:00 2001 From: Christoph Michael Becker Date: Fri, 6 Nov 2020 11:02:11 +0000 Subject: [PATCH] Fix #71872: PHP registerNodeClass and reusing variable names git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@351280 c90b9560-bf6c-de11-be94-00142212c4b1 --- .../dom/domdocument/registernodeclass.xml | 40 +++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/reference/dom/domdocument/registernodeclass.xml b/reference/dom/domdocument/registernodeclass.xml index 7dd5b5e747..301cb90a8b 100644 --- a/reference/dom/domdocument/registernodeclass.xml +++ b/reference/dom/domdocument/registernodeclass.xml @@ -174,6 +174,46 @@ var_dump(get_class($child->ownerDocument)); + + + + + + Custom objects are transient + + + Objects of the registered node classes are transient, i.e. they are + destroyed when they are no longer referenced from PHP code, and recreated + when being retrieved again. That implies that custom property values will be + lost after recreation. + + + +registerNodeClass('DOMElement', 'MyDOMElement'); + +$node = $doc->createElement('a'); +$node->myProp = 'modified value'; +$doc->appendChild($node); + +echo $doc->childNodes[0]->myProp, PHP_EOL; +unset($node); +echo $doc->childNodes[0]->myProp, PHP_EOL; +?>]]> + + &example.outputs; + +