Req->Doc #53693 [Opn->Ver]: ::transformToDoc() $returnClass param docs insufficient

From: Date: Wed, 15 Sep 2021 16:38:03 +0000
Subject: Req->Doc #53693 [Opn->Ver]: ::transformToDoc() $returnClass param docs insufficient
References: 1  Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-19187@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=53693&edit=1

 ID:                 53693
 Updated by:         cmb@php.net
 Reported by:        mat at homedvd dot ca
-Summary:            transformToDoc, different class
+Summary:            ::transformToDoc() $returnClass param docs
                     insufficient
-Status:             Open
+Status:             Verified
-Type:               Feature/Change Request
+Type:               Documentation Problem
 Package:            XSLT related
 Operating System:   Any
 PHP Version:        Irrelevant
 Block user comment: N
 Private report:     N

 New Comment:

This is possible for a long time (at least as of PHP 5.3) by using
the almost undocumented 2nd parameter of ::transformToDoc() which
expects the name of the class to return.  In your case:

echo $processor->transformToDoc( $sourceDOM, DOMDocumentYouCanFancyPrint::class );


Previous Comments:
------------------------------------------------------------------------
[2011-01-08 05:31:04] mat at homedvd dot ca

Description:
------------
It would be very helpful to allow transformToDoc to return a custom class instance, which would have
to extend DOMDocument of course.

The example code provided is simplified.  Far better usage could be made from the child DOMDocument
class -- this is only an example to illustrate the potential.

Test script:
---------------
class DOMDocumentYouCanFancyPrint extends DOMDocument {
    public function __toString() {
        return "<pre>" . htmlentities( $this->saveXML() ) .
"</pre>";
    }
}

...

$processor->registerDocumentClass( "DOMDocumentYouCanFancyPrint" );
echo $processor->transformToDoc( $sourceDOM );

Expected result:
----------------
The expected result would be that the transformToDoc method call returns an instance of
DOMDocumentYouCanFancyPrint.



------------------------------------------------------------------------



--
Edit this bug report at https://bugs.php.net/bug.php?id=53693&edit=1


Thread (2 messages)

« previous php.doc.bugs (#19187) next »