Doc #53693 [Ver->Csd]: ::transformToDoc() $returnClass param docs insufficient
[email protected] Sat, 30 Sep 2023 11:43:39 +0000
| Newsgroups | php.doc.bugs |
|---|---|
| Message-ID | <[email protected]> |
Edit report at https://bugs.php.net/bug.php?id=53693&edit=1 ID: 53693 Updated by: [email protected] 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] [email protected] 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