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

From: Date: Sat, 30 Sep 2023 11:43:39 +0000
Subject: Doc #53693 [Ver->Csd]: ::transformToDoc() $returnClass param docs insufficient
References: 1  Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-19668@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:         nielsdos@php.net
 Reported by:        mat at homedvd dot ca
 Summary:            ::transformToDoc() $returnClass param docs
                     insufficient
-Status:             Verified
+Status:             Closed
 Type:               Documentation Problem
 Package:            XSLT related
 Operating System:   Any
 PHP Version:        Irrelevant
-Assigned To:        
+Assigned To:        nielsdos
 Block user comment: N
 Private report:     N

 New Comment:

The fix for this bug has been committed.
If you are still experiencing this bug, try to check out latest source from https://github.com/php/php-src and re-test.
Thank you for the report, and for helping us make PHP better.

I added documentation for this parameter.


Previous Comments:
------------------------------------------------------------------------
[2021-09-15 16:38:03] cmb@php.net

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 );

------------------------------------------------------------------------
[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 (#19668) next »