Movatterモバイル変換


[0]ホーム

URL:


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

Sign up
Appearance settings

Commitd506b3f

Browse files
[VarDumper] Fix dumping ext-dom virtual properties
1 parent44395ab commitd506b3f

File tree

2 files changed

+229
-29
lines changed

2 files changed

+229
-29
lines changed

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

Lines changed: 177 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,10 @@ public function testCastModernImplementation()
4949
);
5050
}
5151

52-
publicfunctiontestCastNode()
52+
/**
53+
* @requires PHP < 8.4
54+
*/
55+
publicfunctiontestCastNodePriorToPhp84()
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+
publicfunctiontestCastNode()
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-
publicfunctiontestCastText()
169+
/**
170+
* @requires PHP < 8.4
171+
*/
172+
publicfunctiontestCastTextPriorToPhp84()
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+
publicfunctiontestCastText()
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,14 +206,17 @@ 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
170213
);
171214
}
172215

173-
publicfunctiontestCastAttr()
216+
/**
217+
* @requires PHP < 8.4
218+
*/
219+
publicfunctiontestCastAttrPriorToPhp84()
174220
{
175221
$attr =new \DOMAttr('attr','value');
176222

@@ -187,6 +233,26 @@ public function testCastAttr()
187233
);
188234
}
189235

236+
/**
237+
* @requires PHP 8.4
238+
*/
239+
publicfunctiontestCastAttrPrior()
240+
{
241+
$attr =new \DOMAttr('attr','value');
242+
243+
$this->assertDumpMatchesFormat(<<<'EODUMP'
244+
DOMAttr {%A
245+
+name: ~ string
246+
+specified: ~ bool
247+
+value: ~ string
248+
+ownerElement: ~ ?DOMElement
249+
+schemaTypeInfo: ~ mixed
250+
}
251+
EODUMP,
252+
$attr
253+
);
254+
}
255+
190256
/**
191257
* @requires PHP 8.4
192258
*/
@@ -196,17 +262,20 @@ public function testCastModernAttr()
196262

197263
$this->assertDumpMatchesFormat(<<<'EODUMP'
198264
Dom\Attr {%A
199-
+name:? string
200-
+value:? string
201-
+ownerElement:? ?Dom\Element
202-
+specified:true
265+
+name:~ string
266+
+value:~ string
267+
+ownerElement:~ ?Dom\Element
268+
+specified:~ bool
203269
}
204270
EODUMP,
205271
$attr
206272
);
207273
}
208274

209-
publicfunctiontestCastElement()
275+
/**
276+
* @requires PHP < 8.4
277+
*/
278+
publicfunctiontestCastElementPriorToPhp84()
210279
{
211280
$attr =new \DOMElement('foo');
212281

@@ -219,6 +288,22 @@ public function testCastElement()
219288
);
220289
}
221290

291+
/**
292+
* @requires PHP 8.4
293+
*/
294+
publicfunctiontestCastElement()
295+
{
296+
$attr =new \DOMElement('foo');
297+
298+
$this->assertDumpMatchesFormat(<<<'EODUMP'
299+
DOMElement {%A
300+
+tagName: ~ string
301+
%A}
302+
EODUMP,
303+
$attr
304+
);
305+
}
306+
222307
/**
223308
* @requires PHP 8.4
224309
*/
@@ -228,14 +313,17 @@ public function testCastModernElement()
228313

229314
$this->assertDumpMatchesFormat(<<<'EODUMP'
230315
Dom\HTMLElement {%A
231-
+tagName:? string
316+
+tagName:~ string
232317
%A}
233318
EODUMP,
234319
$attr
235320
);
236321
}
237322

238-
publicfunctiontestCastDocumentType()
323+
/**
324+
* @requires PHP < 8.4
325+
*/
326+
publicfunctiontestCastDocumentTypePriorToPhp84()
239327
{
240328
$implementation =new \DOMImplementation();
241329
$type =$implementation->createDocumentType('html','publicId','systemId');
@@ -254,6 +342,28 @@ public function testCastDocumentType()
254342
);
255343
}
256344

345+
/**
346+
* @requires PHP 8.4
347+
*/
348+
publicfunctiontestCastDocumentType()
349+
{
350+
$implementation =new \DOMImplementation();
351+
$type =$implementation->createDocumentType('html','publicId','systemId');
352+
353+
$this->assertDumpMatchesFormat(<<<'EODUMP'
354+
DOMDocumentType {%A
355+
+name: ~ string
356+
+entities: ~ DOMNamedNodeMap
357+
+notations: ~ DOMNamedNodeMap
358+
+publicId: ~ string
359+
+systemId: ~ string
360+
+internalSubset: ~ ?string
361+
}
362+
EODUMP,
363+
$type
364+
);
365+
}
366+
257367
/**
258368
* @requires PHP 8.4
259369
*/
@@ -264,19 +374,22 @@ public function testCastModernDocumentType()
264374

265375
$this->assertDumpMatchesFormat(<<<'EODUMP'
266376
Dom\DocumentType {%A
267-
+name:? string
268-
+entities:? Dom\DtdNamedNodeMap
269-
+notations:? Dom\DtdNamedNodeMap
270-
+publicId:? string
271-
+systemId:? string
272-
+internalSubset:? ?string
377+
+name:~ string
378+
+entities:~ Dom\DtdNamedNodeMap
379+
+notations:~ Dom\DtdNamedNodeMap
380+
+publicId:~ string
381+
+systemId:~ string
382+
+internalSubset:~ ?string
273383
}
274384
EODUMP,
275385
$type
276386
);
277387
}
278388

279-
publicfunctiontestCastProcessingInstruction()
389+
/**
390+
* @requires PHP < 8.4
391+
*/
392+
publicfunctiontestCastProcessingInstructionPriorToPhp84()
280393
{
281394
$entity =new \DOMProcessingInstruction('target','data');
282395

@@ -290,6 +403,23 @@ public function testCastProcessingInstruction()
290403
);
291404
}
292405

406+
/**
407+
* @requires PHP 8.4
408+
*/
409+
publicfunctiontestCastProcessingInstruction()
410+
{
411+
$entity =new \DOMProcessingInstruction('target','data');
412+
413+
$this->assertDumpMatchesFormat(<<<'EODUMP'
414+
DOMProcessingInstruction {%A
415+
+target: ~ string
416+
+data: ~ string
417+
}
418+
EODUMP,
419+
$entity
420+
);
421+
}
422+
293423
/**
294424
* @requires PHP 8.4
295425
*/
@@ -299,16 +429,19 @@ public function testCastModernProcessingInstruction()
299429

300430
$this->assertDumpMatchesFormat(<<<'EODUMP'
301431
Dom\ProcessingInstruction {%A
302-
+data:? string
303-
+length:? int
304-
+target:? string
432+
+data:~ string
433+
+length:~ int
434+
+target:~ string
305435
}
306436
EODUMP,
307437
$entity
308438
);
309439
}
310440

311-
publicfunctiontestCastXPath()
441+
/**
442+
* @requires PHP < 8.4
443+
*/
444+
publicfunctiontestCastXPathPriorToPhp84()
312445
{
313446
$xpath =new \DOMXPath(new \DOMDocument());
314447

@@ -322,6 +455,23 @@ public function testCastXPath()
322455
);
323456
}
324457

458+
/**
459+
* @requires PHP 8.4
460+
*/
461+
publicfunctiontestCastXPath()
462+
{
463+
$xpath =new \DOMXPath(new \DOMDocument());
464+
465+
$this->assertDumpEquals(<<<'EODUMP'
466+
DOMXPath {
467+
+document: ~ DOMDocument
468+
+registerNodeNamespaces: ~ bool
469+
}
470+
EODUMP,
471+
$xpath
472+
);
473+
}
474+
325475
/**
326476
* @requires PHP 8.4
327477
*/
@@ -331,8 +481,8 @@ public function testCastModernXPath()
331481

332482
$this->assertDumpEquals(<<<'EODUMP'
333483
Dom\XPath {
334-
+document:? Dom\Document
335-
+registerNodeNamespaces:? bool
484+
+document:~ Dom\Document
485+
+registerNodeNamespaces:~ bool
336486
}
337487
EODUMP,
338488
$entity

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp