Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit e84fe39

Browse filesBrowse files
[VarDumper] Fix dumping ext-dom virtual properties
1 parent 6584ff5 commit e84fe39
Copy full SHA for e84fe39

File tree

2 files changed

+226
-28
lines changed
Filter options

2 files changed

+226
-28
lines changed

‎src/Symfony/Component/VarDumper/Tests/Caster/DOMCasterTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/VarDumper/Tests/Caster/DOMCasterTest.php
+173-26Lines changed: 173 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,10 @@ public function testCastModernImplementation()
4949
);
5050
}
5151

52-
public function testCastNode()
52+
/**
53+
* @requires PHP < 8.4
54+
*/
55+
public function testCastNodePriorToPhp84()
5356
{
5457
$doc = new \DOMDocument();
5558
$doc->loadXML('<foo><bar/></foo>');
@@ -67,6 +70,27 @@ public function testCastNode()
6770
);
6871
}
6972

73+
/**
74+
* @requires PHP 8.4
75+
*/
76+
public function testCastNode()
77+
{
78+
$doc = new \DOMDocument();
79+
$doc->loadXML('<foo><bar/></foo>');
80+
$node = $doc->documentElement->firstChild;
81+
82+
$this->assertDumpMatchesFormat(<<<'EODUMP'
83+
DOMElement {%A
84+
+ownerDocument: ~ ?DOMDocument
85+
+namespaceURI: ~ ?string
86+
+prefix: ~ string
87+
+localName: ~ ?string
88+
%A}
89+
EODUMP,
90+
$node
91+
);
92+
}
93+
7094
/**
7195
* @requires PHP 8.4
7296
*/
@@ -77,9 +101,9 @@ public function testCastModernNode()
77101

78102
$this->assertDumpMatchesFormat(<<<'EODUMP'
79103
Dom\Element {%A
80-
+baseURI: ? string
81-
+isConnected: ? bool
82-
+ownerDocument: ? ?Dom\Document
104+
+baseURI: ~ string
105+
+isConnected: ~ bool
106+
+ownerDocument: ~ ?Dom\Document
83107
%A}
84108
EODUMP,
85109
$node
@@ -142,7 +166,10 @@ public function testCastHTMLDocument()
142166
);
143167
}
144168

145-
public function testCastText()
169+
/**
170+
* @requires PHP < 8.4
171+
*/
172+
public function testCastTextPriorToPhp84()
146173
{
147174
$doc = new \DOMText('foo');
148175

@@ -155,6 +182,22 @@ public function testCastText()
155182
);
156183
}
157184

185+
/**
186+
* @requires PHP 8.4
187+
*/
188+
public function testCastText()
189+
{
190+
$doc = new \DOMText('foo');
191+
192+
$this->assertDumpMatchesFormat(<<<'EODUMP'
193+
DOMText {%A
194+
+wholeText: ~ string
195+
}
196+
EODUMP,
197+
$doc
198+
);
199+
}
200+
158201
/**
159202
* @requires PHP 8.4
160203
*/
@@ -163,7 +206,7 @@ public function testCastModernText()
163206
$text = \Dom\HTMLDocument::createEmpty()->createTextNode('foo');
164207
$this->assertDumpMatchesFormat(<<<'EODUMP'
165208
Dom\Text {%A
166-
+wholeText: ? string
209+
+wholeText: ~ string
167210
}
168211
EODUMP,
169212
$text
@@ -210,6 +253,26 @@ public function testCastAttr()
210253
);
211254
}
212255

256+
/**
257+
* @requires PHP 8.4
258+
*/
259+
public function testCastAttrPrior()
260+
{
261+
$attr = new \DOMAttr('attr', 'value');
262+
263+
$this->assertDumpMatchesFormat(<<<'EODUMP'
264+
DOMAttr {%A
265+
+name: ~ string
266+
+specified: ~ bool
267+
+value: ~ string
268+
+ownerElement: ~ ?DOMElement
269+
+schemaTypeInfo: ~ mixed
270+
}
271+
EODUMP,
272+
$attr
273+
);
274+
}
275+
213276
/**
214277
* @requires PHP 8.4
215278
*/
@@ -219,17 +282,20 @@ public function testCastModernAttr()
219282

220283
$this->assertDumpMatchesFormat(<<<'EODUMP'
221284
Dom\Attr {%A
222-
+name: ? string
223-
+value: ? string
224-
+ownerElement: ? ?Dom\Element
225-
+specified: ? bool
285+
+name: ~ string
286+
+value: ~ string
287+
+ownerElement: ~ ?Dom\Element
288+
+specified: ~ bool
226289
}
227290
EODUMP,
228291
$attr
229292
);
230293
}
231294

232-
public function testCastElement()
295+
/**
296+
* @requires PHP < 8.4
297+
*/
298+
public function testCastElementPriorToPhp84()
233299
{
234300
$attr = new \DOMElement('foo');
235301

@@ -242,6 +308,22 @@ public function testCastElement()
242308
);
243309
}
244310

311+
/**
312+
* @requires PHP 8.4
313+
*/
314+
public function testCastElement()
315+
{
316+
$attr = new \DOMElement('foo');
317+
318+
$this->assertDumpMatchesFormat(<<<'EODUMP'
319+
DOMElement {%A
320+
+tagName: ~ string
321+
%A}
322+
EODUMP,
323+
$attr
324+
);
325+
}
326+
245327
/**
246328
* @requires PHP 8.4
247329
*/
@@ -251,14 +333,17 @@ public function testCastModernElement()
251333

252334
$this->assertDumpMatchesFormat(<<<'EODUMP'
253335
Dom\HTMLElement {%A
254-
+tagName: ? string
336+
+tagName: ~ string
255337
%A}
256338
EODUMP,
257339
$attr
258340
);
259341
}
260342

261-
public function testCastDocumentType()
343+
/**
344+
* @requires PHP < 8.4
345+
*/
346+
public function testCastDocumentTypePriorToPhp84()
262347
{
263348
$implementation = new \DOMImplementation();
264349
$type = $implementation->createDocumentType('html', 'publicId', 'systemId');
@@ -277,6 +362,28 @@ public function testCastDocumentType()
277362
);
278363
}
279364

365+
/**
366+
* @requires PHP 8.4
367+
*/
368+
public function testCastDocumentType()
369+
{
370+
$implementation = new \DOMImplementation();
371+
$type = $implementation->createDocumentType('html', 'publicId', 'systemId');
372+
373+
$this->assertDumpMatchesFormat(<<<'EODUMP'
374+
DOMDocumentType {%A
375+
+name: ~ string
376+
+entities: ~ DOMNamedNodeMap
377+
+notations: ~ DOMNamedNodeMap
378+
+publicId: ~ string
379+
+systemId: ~ string
380+
+internalSubset: ~ ?string
381+
}
382+
EODUMP,
383+
$type
384+
);
385+
}
386+
280387
/**
281388
* @requires PHP 8.4
282389
*/
@@ -287,19 +394,22 @@ public function testCastModernDocumentType()
287394

288395
$this->assertDumpMatchesFormat(<<<'EODUMP'
289396
Dom\DocumentType {%A
290-
+name: ? string
291-
+entities: ? Dom\DtdNamedNodeMap
292-
+notations: ? Dom\DtdNamedNodeMap
293-
+publicId: ? string
294-
+systemId: ? string
295-
+internalSubset: ? ?string
397+
+name: ~ string
398+
+entities: ~ Dom\DtdNamedNodeMap
399+
+notations: ~ Dom\DtdNamedNodeMap
400+
+publicId: ~ string
401+
+systemId: ~ string
402+
+internalSubset: ~ ?string
296403
}
297404
EODUMP,
298405
$type
299406
);
300407
}
301408

302-
public function testCastProcessingInstruction()
409+
/**
410+
* @requires PHP < 8.4
411+
*/
412+
public function testCastProcessingInstructionPriorToPhp84()
303413
{
304414
$entity = new \DOMProcessingInstruction('target', 'data');
305415

@@ -313,6 +423,23 @@ public function testCastProcessingInstruction()
313423
);
314424
}
315425

426+
/**
427+
* @requires PHP 8.4
428+
*/
429+
public function testCastProcessingInstruction()
430+
{
431+
$entity = new \DOMProcessingInstruction('target', 'data');
432+
433+
$this->assertDumpMatchesFormat(<<<'EODUMP'
434+
DOMProcessingInstruction {%A
435+
+target: ~ string
436+
+data: ~ string
437+
}
438+
EODUMP,
439+
$entity
440+
);
441+
}
442+
316443
/**
317444
* @requires PHP 8.4
318445
*/
@@ -322,16 +449,19 @@ public function testCastModernProcessingInstruction()
322449

323450
$this->assertDumpMatchesFormat(<<<'EODUMP'
324451
Dom\ProcessingInstruction {%A
325-
+data: ? string
326-
+length: ? int
327-
+target: ? string
452+
+data: ~ string
453+
+length: ~ int
454+
+target: ~ string
328455
}
329456
EODUMP,
330457
$entity
331458
);
332459
}
333460

334-
public function testCastXPath()
461+
/**
462+
* @requires PHP < 8.4
463+
*/
464+
public function testCastXPathPriorToPhp84()
335465
{
336466
$xpath = new \DOMXPath(new \DOMDocument());
337467

@@ -345,6 +475,23 @@ public function testCastXPath()
345475
);
346476
}
347477

478+
/**
479+
* @requires PHP 8.4
480+
*/
481+
public function testCastXPath()
482+
{
483+
$xpath = new \DOMXPath(new \DOMDocument());
484+
485+
$this->assertDumpEquals(<<<'EODUMP'
486+
DOMXPath {
487+
+document: ~ DOMDocument
488+
+registerNodeNamespaces: ~ bool
489+
}
490+
EODUMP,
491+
$xpath
492+
);
493+
}
494+
348495
/**
349496
* @requires PHP 8.4
350497
*/
@@ -354,8 +501,8 @@ public function testCastModernXPath()
354501

355502
$this->assertDumpEquals(<<<'EODUMP'
356503
Dom\XPath {
357-
+document: ? Dom\Document
358-
+registerNodeNamespaces: ? bool
504+
+document: ~ Dom\Document
505+
+registerNodeNamespaces: ~ bool
359506
}
360507
EODUMP,
361508
$entity

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.