Skip to content

Commit 44e9fd5

Browse files
committed
Define doXInclude for XSLTProcessor, and test the property
This was added in 8d1427d, 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 f10e1b8 commit 44e9fd5

File tree

5 files changed

+57
-1
lines changed

5 files changed

+57
-1
lines changed

ext/xsl/php_xsl.stub.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,9 @@
7171

7272
class XSLTProcessor
7373
{
74+
/** @var bool */
75+
public $doXInclude;
76+
7477
/**
7578
* @param DOMDocument|SimpleXMLElement $stylesheet
7679
* @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/xinclude/data.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<?xml version="1.0"?>
2+
<data>
3+
<xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="xincluded.xml" parse="xml"/>
4+
</data>

ext/xsl/tests/xinclude/xinclude.phpt

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
--TEST--
2+
doXInclude
3+
--EXTENSIONS--
4+
xsl
5+
dom
6+
--FILE--
7+
<?php
8+
9+
chdir(__DIR__);
10+
11+
$xml = new DOMDocument;
12+
$xml->loadXML('<?xml version="1.0"?><root/>');
13+
14+
$xsl = new DOMDocument;
15+
$xsl->loadXML(<<<XML
16+
<?xml version="1.0"?>
17+
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
18+
<xsl:template match="/root">
19+
<container>
20+
<xsl:value-of select="document('data.xml')/data/content"/>
21+
</container>
22+
</xsl:template>
23+
</xsl:stylesheet>
24+
XML);
25+
26+
$xslt = new XSLTProcessor;
27+
$xslt->doXInclude = true;
28+
$xslt->importStylesheet($xsl);
29+
echo $xslt->transformToXml($xml);
30+
31+
$xslt = new XSLTProcessor;
32+
$xslt->doXInclude = false;
33+
$xslt->importStylesheet($xsl);
34+
echo $xslt->transformToXml($xml);
35+
36+
?>
37+
--EXPECT--
38+
<?xml version="1.0"?>
39+
<container>This is sample content</container>
40+
<?xml version="1.0"?>
41+
<container/>

ext/xsl/tests/xinclude/xincluded.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
<?xml version="1.0"?>
2+
<content>This is sample content</content>

0 commit comments

Comments
 (0)