diff --git a/src/Symfony/Component/VarDumper/Tests/Caster/DOMCasterTest.php b/src/Symfony/Component/VarDumper/Tests/Caster/DOMCasterTest.php
index f3f5e888a3eac..7b79939bfdd75 100644
--- a/src/Symfony/Component/VarDumper/Tests/Caster/DOMCasterTest.php
+++ b/src/Symfony/Component/VarDumper/Tests/Caster/DOMCasterTest.php
@@ -49,7 +49,10 @@ public function testCastModernImplementation()
);
}
- public function testCastNode()
+ /**
+ * @requires PHP < 8.4
+ */
+ public function testCastNodePriorToPhp84()
{
$doc = new \DOMDocument();
$doc->loadXML('');
@@ -67,6 +70,27 @@ public function testCastNode()
);
}
+ /**
+ * @requires PHP 8.4
+ */
+ public function testCastNode()
+ {
+ $doc = new \DOMDocument();
+ $doc->loadXML('');
+ $node = $doc->documentElement->firstChild;
+
+ $this->assertDumpMatchesFormat(<<<'EODUMP'
+ DOMElement {%A
+ +ownerDocument: ~ ?DOMDocument
+ +namespaceURI: ~ ?string
+ +prefix: ~ string
+ +localName: ~ ?string
+ %A}
+ EODUMP,
+ $node
+ );
+ }
+
/**
* @requires PHP 8.4
*/
@@ -77,9 +101,9 @@ public function testCastModernNode()
$this->assertDumpMatchesFormat(<<<'EODUMP'
Dom\Element {%A
- +baseURI: ? string
- +isConnected: ? bool
- +ownerDocument: ? ?Dom\Document
+ +baseURI: ~ string
+ +isConnected: ~ bool
+ +ownerDocument: ~ ?Dom\Document
%A}
EODUMP,
$node
@@ -142,7 +166,10 @@ public function testCastHTMLDocument()
);
}
- public function testCastText()
+ /**
+ * @requires PHP < 8.4
+ */
+ public function testCastTextPriorToPhp84()
{
$doc = new \DOMText('foo');
@@ -155,6 +182,22 @@ public function testCastText()
);
}
+ /**
+ * @requires PHP 8.4
+ */
+ public function testCastText()
+ {
+ $doc = new \DOMText('foo');
+
+ $this->assertDumpMatchesFormat(<<<'EODUMP'
+ DOMText {%A
+ +wholeText: ~ string
+ }
+ EODUMP,
+ $doc
+ );
+ }
+
/**
* @requires PHP 8.4
*/
@@ -163,7 +206,7 @@ public function testCastModernText()
$text = \Dom\HTMLDocument::createEmpty()->createTextNode('foo');
$this->assertDumpMatchesFormat(<<<'EODUMP'
Dom\Text {%A
- +wholeText: ? string
+ +wholeText: ~ string
}
EODUMP,
$text
@@ -199,11 +242,31 @@ public function testCastAttr()
$this->assertDumpMatchesFormat(<<<'EODUMP'
DOMAttr {%A
- +name: ? string
- +specified: ? bool
- +value: ? string
- +ownerElement: ? ?DOMElement
- +schemaTypeInfo: ? mixed
+ +name: ~ string
+ +specified: ~ bool
+ +value: ~ string
+ +ownerElement: ~ ?DOMElement
+ +schemaTypeInfo: ~ mixed
+ }
+ EODUMP,
+ $attr
+ );
+ }
+
+ /**
+ * @requires PHP 8.4
+ */
+ public function testCastAttrPrior()
+ {
+ $attr = new \DOMAttr('attr', 'value');
+
+ $this->assertDumpMatchesFormat(<<<'EODUMP'
+ DOMAttr {%A
+ +name: ~ string
+ +specified: ~ bool
+ +value: ~ string
+ +ownerElement: ~ ?DOMElement
+ +schemaTypeInfo: ~ mixed
}
EODUMP,
$attr
@@ -219,17 +282,20 @@ public function testCastModernAttr()
$this->assertDumpMatchesFormat(<<<'EODUMP'
Dom\Attr {%A
- +name: ? string
- +value: ? string
- +ownerElement: ? ?Dom\Element
- +specified: ? bool
+ +name: ~ string
+ +value: ~ string
+ +ownerElement: ~ ?Dom\Element
+ +specified: ~ bool
}
EODUMP,
$attr
);
}
- public function testCastElement()
+ /**
+ * @requires PHP < 8.4
+ */
+ public function testCastElementPriorToPhp84()
{
$attr = new \DOMElement('foo');
@@ -242,6 +308,22 @@ public function testCastElement()
);
}
+ /**
+ * @requires PHP 8.4
+ */
+ public function testCastElement()
+ {
+ $attr = new \DOMElement('foo');
+
+ $this->assertDumpMatchesFormat(<<<'EODUMP'
+ DOMElement {%A
+ +tagName: ~ string
+ %A}
+ EODUMP,
+ $attr
+ );
+ }
+
/**
* @requires PHP 8.4
*/
@@ -251,14 +333,17 @@ public function testCastModernElement()
$this->assertDumpMatchesFormat(<<<'EODUMP'
Dom\HTMLElement {%A
- +tagName: ? string
+ +tagName: ~ string
%A}
EODUMP,
$attr
);
}
- public function testCastDocumentType()
+ /**
+ * @requires PHP < 8.4
+ */
+ public function testCastDocumentTypePriorToPhp84()
{
$implementation = new \DOMImplementation();
$type = $implementation->createDocumentType('html', 'publicId', 'systemId');
@@ -277,6 +362,28 @@ public function testCastDocumentType()
);
}
+ /**
+ * @requires PHP 8.4
+ */
+ public function testCastDocumentType()
+ {
+ $implementation = new \DOMImplementation();
+ $type = $implementation->createDocumentType('html', 'publicId', 'systemId');
+
+ $this->assertDumpMatchesFormat(<<<'EODUMP'
+ DOMDocumentType {%A
+ +name: ~ string
+ +entities: ~ DOMNamedNodeMap
+ +notations: ~ DOMNamedNodeMap
+ +publicId: ~ string
+ +systemId: ~ string
+ +internalSubset: ~ ?string
+ }
+ EODUMP,
+ $type
+ );
+ }
+
/**
* @requires PHP 8.4
*/
@@ -287,19 +394,22 @@ public function testCastModernDocumentType()
$this->assertDumpMatchesFormat(<<<'EODUMP'
Dom\DocumentType {%A
- +name: ? string
- +entities: ? Dom\DtdNamedNodeMap
- +notations: ? Dom\DtdNamedNodeMap
- +publicId: ? string
- +systemId: ? string
- +internalSubset: ? ?string
+ +name: ~ string
+ +entities: ~ Dom\DtdNamedNodeMap
+ +notations: ~ Dom\DtdNamedNodeMap
+ +publicId: ~ string
+ +systemId: ~ string
+ +internalSubset: ~ ?string
}
EODUMP,
$type
);
}
- public function testCastProcessingInstruction()
+ /**
+ * @requires PHP < 8.4
+ */
+ public function testCastProcessingInstructionPriorToPhp84()
{
$entity = new \DOMProcessingInstruction('target', 'data');
@@ -313,6 +423,23 @@ public function testCastProcessingInstruction()
);
}
+ /**
+ * @requires PHP 8.4
+ */
+ public function testCastProcessingInstruction()
+ {
+ $entity = new \DOMProcessingInstruction('target', 'data');
+
+ $this->assertDumpMatchesFormat(<<<'EODUMP'
+ DOMProcessingInstruction {%A
+ +target: ~ string
+ +data: ~ string
+ }
+ EODUMP,
+ $entity
+ );
+ }
+
/**
* @requires PHP 8.4
*/
@@ -322,16 +449,19 @@ public function testCastModernProcessingInstruction()
$this->assertDumpMatchesFormat(<<<'EODUMP'
Dom\ProcessingInstruction {%A
- +data: ? string
- +length: ? int
- +target: ? string
+ +data: ~ string
+ +length: ~ int
+ +target: ~ string
}
EODUMP,
$entity
);
}
- public function testCastXPath()
+ /**
+ * @requires PHP < 8.4
+ */
+ public function testCastXPathPriorToPhp84()
{
$xpath = new \DOMXPath(new \DOMDocument());
@@ -345,6 +475,23 @@ public function testCastXPath()
);
}
+ /**
+ * @requires PHP 8.4
+ */
+ public function testCastXPath()
+ {
+ $xpath = new \DOMXPath(new \DOMDocument());
+
+ $this->assertDumpEquals(<<<'EODUMP'
+ DOMXPath {
+ +document: ~ DOMDocument
+ +registerNodeNamespaces: ~ bool
+ }
+ EODUMP,
+ $xpath
+ );
+ }
+
/**
* @requires PHP 8.4
*/
@@ -354,8 +501,8 @@ public function testCastModernXPath()
$this->assertDumpEquals(<<<'EODUMP'
Dom\XPath {
- +document: ? Dom\Document
- +registerNodeNamespaces: ? bool
+ +document: ~ Dom\Document
+ +registerNodeNamespaces: ~ bool
}
EODUMP,
$entity
diff --git a/src/Symfony/Component/VarDumper/Tests/Caster/XmlReaderCasterTest.php b/src/Symfony/Component/VarDumper/Tests/Caster/XmlReaderCasterTest.php
index 635c4c4e8f4db..67feddba0f542 100644
--- a/src/Symfony/Component/VarDumper/Tests/Caster/XmlReaderCasterTest.php
+++ b/src/Symfony/Component/VarDumper/Tests/Caster/XmlReaderCasterTest.php
@@ -34,7 +34,10 @@ protected function tearDown(): void
$this->reader->close();
}
- public function testParserProperty()
+ /**
+ * @requires PHP < 8.4
+ */
+ public function testParserPropertyPriorToPhp84()
{
$this->reader->setParserProperty(\XMLReader::SUBST_ENTITIES, true);
@@ -53,6 +56,33 @@ public function testParserProperty()
}
/**
+ * @requires PHP 8.4
+ */
+ public function testParserProperty()
+ {
+ $this->reader->setParserProperty(\XMLReader::SUBST_ENTITIES, true);
+
+ $expectedDump = <<<'EODUMP'
+XMLReader {%A
+ +nodeType: ~ int
+%A
+ parserProperties: {
+ SUBST_ENTITIES: true
+ …3
+ }
+ …12
+}
+EODUMP;
+
+ $this->assertDumpMatchesFormat($expectedDump, $this->reader);
+ }
+
+ /**
+ * This test only work before PHP 8.4. In PHP 8.4, XMLReader properties are virtual
+ * and their values are not dumped.
+ *
+ * @requires PHP < 8.4
+ *
* @dataProvider provideNodes
*/
public function testNodes($seek, $expectedDump)
@@ -245,7 +275,10 @@ public static function provideNodes()
];
}
- public function testWithUninitializedXMLReader()
+ /**
+ * @requires PHP < 8.4
+ */
+ public function testWithUninitializedXMLReaderPriorToPhp84()
{
$this->reader = new \XMLReader();
@@ -254,6 +287,24 @@ public function testWithUninitializedXMLReader()
+nodeType: NONE
…13
}
+EODUMP;
+
+ $this->assertDumpMatchesFormat($expectedDump, $this->reader);
+ }
+
+ /**
+ * @requires PHP 8.4
+ */
+ public function testWithUninitializedXMLReader()
+ {
+ $this->reader = new \XMLReader();
+
+ $expectedDump = <<<'EODUMP'
+XMLReader {%A
+ +nodeType: ~ int
+%A
+ …13
+}
EODUMP;
$this->assertDumpMatchesFormat($expectedDump, $this->reader);