@@ -135,7 +135,7 @@ public function parse() {
135
135
/* Consume the next input character */
136
136
$ char = $ this ->stream ->char ();
137
137
$ lastFourChars .= $ char ;
138
- if (strlen ($ lastFourChars ) > 4 ) $ lastFourChars = substr ($ lastFourChars , -4 );
138
+ if (strlen ($ lastFourChars ?? '' ) > 4 ) $ lastFourChars = substr ($ lastFourChars ?? '' , -4 );
139
139
140
140
// see below for meaning
141
141
$ hyp_cond =
@@ -213,7 +213,7 @@ public function parse() {
213
213
} elseif (
214
214
$ char === '> ' &&
215
215
$ gt_cond &&
216
- substr ($ lastFourChars , 1 ) === '--> '
216
+ substr ($ lastFourChars ?? '' , 1 ) === '--> '
217
217
) {
218
218
/* If the content model flag is set to either the RCDATA state or
219
219
the CDATA state, and the escape flag is true, and the last three
@@ -248,7 +248,7 @@ public function parse() {
248
248
'data ' => $ char . $ chars
249
249
));
250
250
$ lastFourChars .= $ chars ;
251
- if (strlen ($ lastFourChars ) > 4 ) $ lastFourChars = substr ($ lastFourChars , -4 );
251
+ if (strlen ($ lastFourChars ?? '' ) > 4 ) $ lastFourChars = substr ($ lastFourChars ?? '' , -4 );
252
252
253
253
} else {
254
254
/* Anything else
@@ -274,7 +274,7 @@ public function parse() {
274
274
));
275
275
276
276
$ lastFourChars .= $ chars ;
277
- if (strlen ($ lastFourChars ) > 4 ) $ lastFourChars = substr ($ lastFourChars , -4 );
277
+ if (strlen ($ lastFourChars ?? '' ) > 4 ) $ lastFourChars = substr ($ lastFourChars ?? '' , -4 );
278
278
279
279
$ state = 'data ' ;
280
280
}
@@ -351,7 +351,7 @@ public function parse() {
351
351
point), then switch to the tag name state. (Don't emit the token
352
352
yet; further details will be filled in before it is emitted.) */
353
353
$ this ->token = array (
354
- 'name ' => strtolower ($ char ),
354
+ 'name ' => strtolower ($ char ?? '' ),
355
355
'type ' => self ::STARTTAG ,
356
356
'attr ' => array ()
357
357
);
@@ -427,7 +427,7 @@ public function parse() {
427
427
) {
428
428
/* If the content model flag is set to the RCDATA or CDATA
429
429
states... */
430
- $ name = strtolower ($ this ->stream ->charsWhile (self ::ALPHA ));
430
+ $ name = strtolower ($ this ->stream ->charsWhile (self ::ALPHA ) ?? '' );
431
431
$ following = $ this ->stream ->char ();
432
432
$ this ->stream ->unget ();
433
433
if (
@@ -489,7 +489,7 @@ public function parse() {
489
489
switch to the tag name state. (Don't emit the token yet; further details
490
490
will be filled in before it is emitted.) */
491
491
$ this ->token = array (
492
- 'name ' => strtolower ($ char ),
492
+ 'name ' => strtolower ($ char ?? '' ),
493
493
'type ' => self ::ENDTAG
494
494
);
495
495
@@ -635,7 +635,7 @@ public function parse() {
635
635
point), and its value to the empty string. Switch to the
636
636
attribute name state.*/
637
637
$ this ->token ['attr ' ][] = array (
638
- 'name ' => strtolower ($ char ),
638
+ 'name ' => strtolower ($ char ?? '' ),
639
639
'value ' => ''
640
640
);
641
641
@@ -716,7 +716,7 @@ public function parse() {
716
716
state. */
717
717
$ chars = $ this ->stream ->charsWhile (self ::UPPER_ALPHA );
718
718
719
- $ last = count ($ this ->token ['attr ' ]) - 1 ;
719
+ $ last = count ($ this ->token ['attr ' ] ?? [] ) - 1 ;
720
720
$ this ->token ['attr ' ][$ last ]['name ' ] .= strtolower ($ char . $ chars );
721
721
722
722
$ state = 'attribute name ' ;
@@ -750,7 +750,7 @@ public function parse() {
750
750
Stay in the attribute name state. */
751
751
$ chars = $ this ->stream ->charsUntil ("\t\n\x0C /=> \"' " . self ::UPPER_ALPHA );
752
752
753
- $ last = count ($ this ->token ['attr ' ]) - 1 ;
753
+ $ last = count ($ this ->token ['attr ' ] ?? [] ) - 1 ;
754
754
$ this ->token ['attr ' ][$ last ]['name ' ] .= $ char . $ chars ;
755
755
756
756
$ state = 'attribute name ' ;
@@ -803,7 +803,7 @@ public function parse() {
803
803
point), and its value to the empty string. Switch to the
804
804
attribute name state. */
805
805
$ this ->token ['attr ' ][] = array (
806
- 'name ' => strtolower ($ char ),
806
+ 'name ' => strtolower ($ char ?? '' ),
807
807
'value ' => ''
808
808
);
809
809
@@ -910,7 +910,7 @@ public function parse() {
910
910
/* Anything else
911
911
Append the current input character to the current attribute's value.
912
912
Switch to the attribute value (unquoted) state. */
913
- $ last = count ($ this ->token ['attr ' ]) - 1 ;
913
+ $ last = count ($ this ->token ['attr ' ] ?? [] ) - 1 ;
914
914
$ this ->token ['attr ' ][$ last ]['value ' ] .= $ char ;
915
915
916
916
$ state = 'attribute value (unquoted) ' ;
@@ -950,7 +950,7 @@ public function parse() {
950
950
Stay in the attribute value (double-quoted) state. */
951
951
$ chars = $ this ->stream ->charsUntil ('"& ' );
952
952
953
- $ last = count ($ this ->token ['attr ' ]) - 1 ;
953
+ $ last = count ($ this ->token ['attr ' ] ?? [] ) - 1 ;
954
954
$ this ->token ['attr ' ][$ last ]['value ' ] .= $ char . $ chars ;
955
955
956
956
$ state = 'attribute value (double-quoted) ' ;
@@ -988,7 +988,7 @@ public function parse() {
988
988
Stay in the attribute value (single-quoted) state. */
989
989
$ chars = $ this ->stream ->charsUntil ("'& " );
990
990
991
- $ last = count ($ this ->token ['attr ' ]) - 1 ;
991
+ $ last = count ($ this ->token ['attr ' ] ?? [] ) - 1 ;
992
992
$ this ->token ['attr ' ][$ last ]['value ' ] .= $ char . $ chars ;
993
993
994
994
$ state = 'attribute value (single-quoted) ' ;
@@ -1049,7 +1049,7 @@ public function parse() {
1049
1049
Stay in the attribute value (unquoted) state. */
1050
1050
$ chars = $ this ->stream ->charsUntil ("\t\n\x0c &> \"'= " );
1051
1051
1052
- $ last = count ($ this ->token ['attr ' ]) - 1 ;
1052
+ $ last = count ($ this ->token ['attr ' ] ?? [] ) - 1 ;
1053
1053
$ this ->token ['attr ' ][$ last ]['value ' ] .= $ char . $ chars ;
1054
1054
1055
1055
$ state = 'attribute value (unquoted) ' ;
@@ -1179,7 +1179,7 @@ public function parse() {
1179
1179
/* Otherwise if the next seven characters are a case-insensitive match
1180
1180
for the word "DOCTYPE", then consume those characters and switch to the
1181
1181
DOCTYPE state. */
1182
- } elseif (strtoupper ($ alpha ) === 'DOCTYPE ' ) {
1182
+ } elseif (strtoupper ($ alpha ?? '' ) === 'DOCTYPE ' ) {
1183
1183
$ state = 'DOCTYPE ' ;
1184
1184
1185
1185
// XXX not implemented
@@ -1526,7 +1526,7 @@ public function parse() {
1526
1526
the character's code point). Switch to the DOCTYPE name
1527
1527
state. */
1528
1528
$ this ->token = array (
1529
- 'name ' => strtolower ($ char ),
1529
+ 'name ' => strtolower ($ char ?? '' ),
1530
1530
'type ' => self ::DOCTYPE ,
1531
1531
'error ' => true
1532
1532
);
@@ -1589,7 +1589,7 @@ public function parse() {
1589
1589
Append the lowercase version of the input character
1590
1590
(add 0x0020 to the character's code point) to the current
1591
1591
DOCTYPE token's name. Stay in the DOCTYPE name state. */
1592
- $ this ->token ['name ' ] .= strtolower ($ char );
1592
+ $ this ->token ['name ' ] .= strtolower ($ char ?? '' );
1593
1593
1594
1594
} elseif ($ char === false ) {
1595
1595
/* EOF
@@ -2289,7 +2289,7 @@ private function consumeCharacterReference($allowed = false, $inattr = false) {
2289
2289
// alphanumeric so we can just concat it to whatever we get later).
2290
2290
$ this ->stream ->unget ();
2291
2291
if ($ char !== false ) {
2292
- $ chars = substr ($ chars , 0 , -1 );
2292
+ $ chars = substr ($ chars ?? '' , 0 , -1 );
2293
2293
}
2294
2294
2295
2295
/* If no match can be made, then this is a parse error.
@@ -2305,7 +2305,7 @@ private function consumeCharacterReference($allowed = false, $inattr = false) {
2305
2305
/* If the last character matched is not a U+003B SEMICOLON
2306
2306
(;), there is a parse error. */
2307
2307
$ semicolon = true ;
2308
- if (substr ($ id , -1 ) !== '; ' ) {
2308
+ if (substr ($ id ?? '' , -1 ) !== '; ' ) {
2309
2309
$ this ->emitToken (array (
2310
2310
'type ' => self ::PARSEERROR ,
2311
2311
'data ' => 'named-entity-without-semicolon '
@@ -2324,8 +2324,8 @@ private function consumeCharacterReference($allowed = false, $inattr = false) {
2324
2324
and nothing is returned. */
2325
2325
if ($ inattr && !$ semicolon ) {
2326
2326
// The next character is either the next character in $chars or in the stream.
2327
- if (strlen ($ chars ) > strlen ($ id )) {
2328
- $ next = substr ($ chars , strlen ($ id ), 1 );
2327
+ if (strlen ($ chars ?? '' ) > strlen ($ id ?? '' )) {
2328
+ $ next = substr ($ chars ?? '' , strlen ($ id ?? '' ), 1 );
2329
2329
} else {
2330
2330
$ next = $ this ->stream ->char ();
2331
2331
$ this ->stream ->unget ();
@@ -2342,7 +2342,7 @@ private function consumeCharacterReference($allowed = false, $inattr = false) {
2342
2342
/* Otherwise, return a character token for the character
2343
2343
corresponding to the character reference name (as given
2344
2344
by the second column of the named character references table). */
2345
- return HTML5_Data::utf8chr ($ codepoint ) . substr ($ chars , strlen ($ id ));
2345
+ return HTML5_Data::utf8chr ($ codepoint ) . substr ($ chars ?? '' , strlen ($ id ?? '' ));
2346
2346
}
2347
2347
}
2348
2348
@@ -2359,7 +2359,7 @@ private function characterReferenceInAttributeValue($allowed = false) {
2359
2359
? '& '
2360
2360
: $ entity ;
2361
2361
2362
- $ last = count ($ this ->token ['attr ' ]) - 1 ;
2362
+ $ last = count ($ this ->token ['attr ' ] ?? [] ) - 1 ;
2363
2363
$ this ->token ['attr ' ][$ last ]['value ' ] .= $ char ;
2364
2364
2365
2365
/* Finally, switch back to the attribute value state that you
@@ -2377,7 +2377,7 @@ protected function emitToken($token, $checkStream = true, $dry = false) {
2377
2377
}
2378
2378
}
2379
2379
if ($ token ['type ' ] === self ::ENDTAG && !empty ($ token ['attr ' ])) {
2380
- for ($ i = 0 ; $ i < count ($ token ['attr ' ]); $ i ++) {
2380
+ for ($ i = 0 ; $ i < count ($ token ['attr ' ] ?? [] ); $ i ++) {
2381
2381
$ this ->emitToken (array (
2382
2382
'type ' => self ::PARSEERROR ,
2383
2383
'data ' => 'attributes-in-end-tag '
0 commit comments