Skip to content

Commit aeb4aca

Browse files
committed
Declare tidyNode properties as readonly
1 parent 768d00f commit aeb4aca

File tree

6 files changed

+311
-122
lines changed

6 files changed

+311
-122
lines changed

ext/tidy/tests/010.phpt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ var_dump($a->head());
1212

1313
?>
1414
--EXPECTF--
15-
object(tidyNode)#2 (8) {
15+
object(tidyNode)#2 (9) {
1616
["value"]=>
1717
string(94) "<html>
1818
<head>
@@ -31,6 +31,8 @@ object(tidyNode)#2 (8) {
3131
int(1)
3232
["proprietary"]=>
3333
bool(false)
34+
["id"]=>
35+
NULL
3436
["attribute"]=>
3537
NULL
3638
["child"]=>

ext/tidy/tests/012.phpt

Lines changed: 30 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ object(tidyNode)#5 (9) {
148148
["child"]=>
149149
array(1) {
150150
[0]=>
151-
object(tidyNode)#7 (8) {
151+
object(tidyNode)#7 (9) {
152152
["value"]=>
153153
string(2) "Hi"
154154
["name"]=>
@@ -161,6 +161,8 @@ object(tidyNode)#5 (9) {
161161
int(46)
162162
["proprietary"]=>
163163
bool(false)
164+
["id"]=>
165+
NULL
164166
["attribute"]=>
165167
NULL
166168
["child"]=>
@@ -189,7 +191,7 @@ object(tidyNode)#5 (9) {
189191
["child"]=>
190192
array(2) {
191193
[0]=>
192-
object(tidyNode)#9 (8) {
194+
object(tidyNode)#9 (9) {
193195
["value"]=>
194196
string(3) "Bye"
195197
["name"]=>
@@ -202,6 +204,8 @@ object(tidyNode)#5 (9) {
202204
int(55)
203205
["proprietary"]=>
204206
bool(false)
207+
["id"]=>
208+
NULL
205209
["attribute"]=>
206210
NULL
207211
["child"]=>
@@ -228,7 +232,7 @@ object(tidyNode)#5 (9) {
228232
["child"]=>
229233
array(1) {
230234
[0]=>
231-
object(tidyNode)#11 (8) {
235+
object(tidyNode)#11 (9) {
232236
["value"]=>
233237
string(4) "Test"
234238
["name"]=>
@@ -241,6 +245,8 @@ object(tidyNode)#5 (9) {
241245
int(61)
242246
["proprietary"]=>
243247
bool(false)
248+
["id"]=>
249+
NULL
244250
["attribute"]=>
245251
NULL
246252
["child"]=>
@@ -273,7 +279,7 @@ object(tidyNode)#6 (9) {
273279
["child"]=>
274280
array(1) {
275281
[0]=>
276-
object(tidyNode)#7 (8) {
282+
object(tidyNode)#7 (9) {
277283
["value"]=>
278284
string(2) "Hi"
279285
["name"]=>
@@ -286,6 +292,8 @@ object(tidyNode)#6 (9) {
286292
int(46)
287293
["proprietary"]=>
288294
bool(false)
295+
["id"]=>
296+
NULL
289297
["attribute"]=>
290298
NULL
291299
["child"]=>
@@ -294,7 +302,7 @@ object(tidyNode)#6 (9) {
294302
}
295303
}
296304
bool(true)
297-
object(tidyNode)#7 (8) {
305+
object(tidyNode)#7 (9) {
298306
["value"]=>
299307
string(2) "Hi"
300308
["name"]=>
@@ -307,6 +315,8 @@ object(tidyNode)#7 (8) {
307315
int(46)
308316
["proprietary"]=>
309317
bool(false)
318+
["id"]=>
319+
NULL
310320
["attribute"]=>
311321
NULL
312322
["child"]=>
@@ -332,7 +342,7 @@ object(tidyNode)#8 (9) {
332342
["child"]=>
333343
array(2) {
334344
[0]=>
335-
object(tidyNode)#9 (8) {
345+
object(tidyNode)#9 (9) {
336346
["value"]=>
337347
string(3) "Bye"
338348
["name"]=>
@@ -345,6 +355,8 @@ object(tidyNode)#8 (9) {
345355
int(55)
346356
["proprietary"]=>
347357
bool(false)
358+
["id"]=>
359+
NULL
348360
["attribute"]=>
349361
NULL
350362
["child"]=>
@@ -371,7 +383,7 @@ object(tidyNode)#8 (9) {
371383
["child"]=>
372384
array(1) {
373385
[0]=>
374-
object(tidyNode)#11 (8) {
386+
object(tidyNode)#11 (9) {
375387
["value"]=>
376388
string(4) "Test"
377389
["name"]=>
@@ -384,6 +396,8 @@ object(tidyNode)#8 (9) {
384396
int(61)
385397
["proprietary"]=>
386398
bool(false)
399+
["id"]=>
400+
NULL
387401
["attribute"]=>
388402
NULL
389403
["child"]=>
@@ -394,7 +408,7 @@ object(tidyNode)#8 (9) {
394408
}
395409
}
396410
bool(true)
397-
object(tidyNode)#9 (8) {
411+
object(tidyNode)#9 (9) {
398412
["value"]=>
399413
string(3) "Bye"
400414
["name"]=>
@@ -407,6 +421,8 @@ object(tidyNode)#9 (8) {
407421
int(55)
408422
["proprietary"]=>
409423
bool(false)
424+
["id"]=>
425+
NULL
410426
["attribute"]=>
411427
NULL
412428
["child"]=>
@@ -432,7 +448,7 @@ object(tidyNode)#10 (9) {
432448
["child"]=>
433449
array(1) {
434450
[0]=>
435-
object(tidyNode)#11 (8) {
451+
object(tidyNode)#11 (9) {
436452
["value"]=>
437453
string(4) "Test"
438454
["name"]=>
@@ -445,6 +461,8 @@ object(tidyNode)#10 (9) {
445461
int(61)
446462
["proprietary"]=>
447463
bool(false)
464+
["id"]=>
465+
NULL
448466
["attribute"]=>
449467
NULL
450468
["child"]=>
@@ -453,7 +471,7 @@ object(tidyNode)#10 (9) {
453471
}
454472
}
455473
bool(true)
456-
object(tidyNode)#11 (8) {
474+
object(tidyNode)#11 (9) {
457475
["value"]=>
458476
string(4) "Test"
459477
["name"]=>
@@ -466,6 +484,8 @@ object(tidyNode)#11 (8) {
466484
int(61)
467485
["proprietary"]=>
468486
bool(false)
487+
["id"]=>
488+
NULL
469489
["attribute"]=>
470490
NULL
471491
["child"]=>

ext/tidy/tests/036.phpt

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
--TEST--
2+
Test readonly tidyNode properties
3+
--EXTENSIONS--
4+
tidy
5+
--FILE--
6+
<?php
7+
8+
$tidy = tidy_parse_string("<HTML><BODY BGCOLOR=#FFFFFF ALINK=#000000></BODY></HTML>");
9+
$node = $tidy->body();
10+
11+
try {
12+
$node->value = "";
13+
} catch (Error $exception) {
14+
echo $exception->getMessage() . "\n";
15+
}
16+
17+
try {
18+
$node->name = "";
19+
} catch (Error $exception) {
20+
echo $exception->getMessage() . "\n";
21+
}
22+
23+
try {
24+
$node->type = 1;
25+
} catch (Error $exception) {
26+
echo $exception->getMessage() . "\n";
27+
}
28+
29+
try {
30+
$node->line = 1;
31+
} catch (Error $exception) {
32+
echo $exception->getMessage() . "\n";
33+
}
34+
35+
try {
36+
$node->column = 1;
37+
} catch (Error $exception) {
38+
echo $exception->getMessage() . "\n";
39+
}
40+
41+
try {
42+
$node->proprietary = true;
43+
} catch (Error $exception) {
44+
echo $exception->getMessage() . "\n";
45+
}
46+
47+
try {
48+
$node->id = null;
49+
} catch (Error $exception) {
50+
echo $exception->getMessage() . "\n";
51+
}
52+
53+
try {
54+
$node->attribute = [];
55+
} catch (Error $exception) {
56+
echo $exception->getMessage() . "\n";
57+
}
58+
59+
try {
60+
$node->child = [];
61+
} catch (Error $exception) {
62+
echo $exception->getMessage() . "\n";
63+
}
64+
65+
?>
66+
--EXPECT--
67+
Cannot modify readonly property tidyNode::$value
68+
Cannot modify readonly property tidyNode::$name
69+
Cannot modify readonly property tidyNode::$type
70+
Cannot modify readonly property tidyNode::$line
71+
Cannot modify readonly property tidyNode::$column
72+
Cannot modify readonly property tidyNode::$proprietary
73+
Cannot modify readonly property tidyNode::$id
74+
Cannot modify readonly property tidyNode::$attribute
75+
Cannot modify readonly property tidyNode::$child

0 commit comments

Comments
 (0)