Skip to content

Commit ed65211

Browse files
committed
Define cloneDocument for XSLTProcessor, and test the property
This was introduced in 5c039bb, but never defined on the stub. It was more or less fine when dynamic properties were not deprecated, but now they throw a deprecation warning. To fix it, define on the stub. This should also help discoverability of the functionality.
1 parent 44e9fd5 commit ed65211

File tree

3 files changed

+55
-1
lines changed

3 files changed

+55
-1
lines changed

ext/xsl/php_xsl.stub.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,9 @@ class XSLTProcessor
7474
/** @var bool */
7575
public $doXInclude;
7676

77+
/** @var bool */
78+
public $cloneDocument;
79+
7780
/**
7881
* @param DOMDocument|SimpleXMLElement $stylesheet
7982
* @tentative-return-type

ext/xsl/php_xsl_arginfo.h

Lines changed: 7 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ext/xsl/tests/cloneDocument.phpt

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
--TEST--
2+
cloneDocument
3+
--EXTENSIONS--
4+
xsl
5+
dom
6+
--FILE--
7+
<?php
8+
9+
$xml = new DOMDocument;
10+
$xml->loadXML('<?xml version="1.0"?><root><foo>hello</foo></root>');
11+
12+
function test() {
13+
global $xml;
14+
$xml->documentElement->firstChild->textContent = "bye";
15+
}
16+
17+
$xsl = new DOMDocument;
18+
$xsl->loadXML(<<<XML
19+
<?xml version="1.0"?>
20+
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:php="http://php.net/xsl" version="1.0">
21+
<xsl:template match="/root">
22+
<xsl:value-of select="php:function('test')"/>
23+
<xsl:value-of select="//root/foo"/>
24+
</xsl:template>
25+
</xsl:stylesheet>
26+
XML);
27+
28+
$xslt = new XSLTProcessor;
29+
$xslt->registerPHPFunctions();
30+
$xslt->cloneDocument = true;
31+
$xslt->importStylesheet($xsl);
32+
echo $xslt->transformToXml($xml);
33+
34+
$xslt = new XSLTProcessor;
35+
$xslt->registerPHPFunctions();
36+
$xslt->cloneDocument = false;
37+
$xslt->importStylesheet($xsl);
38+
echo $xslt->transformToXml($xml);
39+
40+
?>
41+
--EXPECT--
42+
<?xml version="1.0"?>
43+
hello
44+
<?xml version="1.0"?>
45+
bye

0 commit comments

Comments
 (0)