1--TEST-- 2Test: registerNodeClass() 3--SKIPIF-- 4<?php require_once('skipif.inc'); ?> 5--FILE-- 6<?php 7class myAttribute extends DOMAttr { 8 function testit() { return "HELLO Attribute"; } 9} 10 11class myElement extends DOMElement { 12 function testit() { return "HELLO Element"; } 13} 14 15$doc = new DOMDocument(); 16$doc->registerNodeClass('DOMAttr', 'myAttribute'); 17$doc->registerNodeClass('DOMElement', 'myElement'); 18$doc->appendChild(new DOMElement('root')); 19$root = $doc->documentElement; 20$root->setAttribute('a', 'a1'); 21echo get_class($root), "\n"; 22print $root->testit()."\n"; 23$attr = $root->getAttributeNode('a'); 24echo get_class($attr), "\n"; 25print $attr->testit()."\n"; 26unset($attr); 27$doc->registerNodeClass('DOMAttr', NULL); 28$attr = $root->getAttributeNode('a'); 29echo get_class($attr), "\n"; 30print $attr->testit()."\n"; 31?> 32--EXPECTF-- 33myElement 34HELLO Element 35myAttribute 36HELLO Attribute 37DOMAttr 38 39Fatal error: Uncaught Error: Call to undefined method DOMAttr::testit() in %s:25 40Stack trace: 41#0 {main} 42 thrown in %s on line 25 43