note 116070 added to class.domimplementation

From: Date: Wed, 05 Nov 2014 22:59:35 +0000
Subject: note 116070 added to class.domimplementation
Groups: php.notes 
Request: Send a blank email to php-notes+get-200794@lists.php.net to get a copy of this message
Why not use the DOMImplementation to directly register your DOM Class extensions ? <?php namespace My; class Implementation extends \DOMImplementation { private $doc; public function __construct(){return $this->createDocument();} public function __get($name){return $this->doc->{$name};} public function __set($name,$value){$this->doc->{$name}=$value;} public function __isset($name){return isset($this->doc->{$name});} public function __unset($name){return $this->doc->__unset($name);} public function __call($name,$args){return call_user_func_array(array($this->doc,$name),$args);} public function createDocument($namespaceURI=null,$qualifiedName=null,DOMDocumentType $docType=null) { $this->doc=parent::createDocument($namespaceURI,$qualifiedName,$docType); $this->doc->xmlVersion='1.0'; $this->doc->xmlEncoding='UTF-8'; $this->doc->registerNodeClass('DOMDocument','My\Document'); $this->doc->registerNodeClass('DOMDocumentFragment','My\DocumentFragment'); $this->doc->registerNodeClass('DOMElement','My\Element'); $this->doc->registerNodeClass('DOMComment','My\Comment'); $this->doc->registerNodeClass('DOMNode','My\Node'); /* …, …, … */ return $this->doc; } } ?> ---- Server IP: 72.52.91.14 Probable Submitter: 83.99.17.74 ---- Manual Page -- http://php.net/manual/en/class.domimplementation.php Edit -- https://master.php.net/note/edit/116070 Del: integrated -- https://master.php.net/note/delete/116070/integrated Del: useless -- https://master.php.net/note/delete/116070/useless Del: bad code -- https://master.php.net/note/delete/116070/bad+code Del: spam -- https://master.php.net/note/delete/116070/spam Del: non-english -- https://master.php.net/note/delete/116070/non-english Del: in docs -- https://master.php.net/note/delete/116070/in+docs Del: other reasons-- https://master.php.net/note/delete/116070 Reject -- https://master.php.net/note/reject/116070 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#200794) next »