note 64339 modified in language.oop5.overloading by danbrown

From: Date: Fri, 14 Nov 2008 17:17:49 +0000
Subject: note 64339 modified in language.oop5.overloading by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-146545@lists.php.net to get a copy of this message
Regarding the post by TJ earlier, about the problems extending DOMElement. Yes, it is true that you can't set extDOMElement::ownerDocument directly; however, you could append the extDOMElement to a DOMDocument in __construct(), which indirectly sets ownerDocument. It should work something like so: <?php class extDOMElement extends DOMElement { public function __construct(DOMDocument $doc) { $doc->appendChild($this); //extDOMElement::ownerDocument is now equal to the object that $doc points to } } ?> Now, I admit I've never actually needed to do this, but I see no reason why it shouldn't work. --was-- Regarding the post by TJ earlier, about the problems extending DOMElement. Yes, it is true that you can't set extDOMElement::ownerDocument directly; however, you could append the extDOMElement to a DOMDocument in __construct(), which indirectly sets ownerDocument. It should work something like so: class extDOMElement extends DOMElement { public function __construct(DOMDocument $doc) { $doc->appendChild($this); //extDOMElement::ownerDocument is now equal to the object that $doc points to } } Now, I admit I've never actually needed to do this, but I see no reason why it shouldn't work. http://php.net/manual/en/language.oop5.overloading.php

« previous php.notes (#146545) next »