Skip to content

Commit 7d79c59

Browse files
jrfnlgsherwood
authored andcommitted
PHP 8.0 | Tokenizer/PHP: bug fix
PHP 8.0 elevate a number of notices/warnings to errors, which now exposes a bug in the `goto` tokenizer logic. Error: `Trying to access array offset on value of type null` Fixed by making sure that the token being accessed is an array before trying to access it.
1 parent a43ae18 commit 7d79c59

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/Tokenizers/PHP.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1246,7 +1246,8 @@ function return types. We want to keep the parenthesis map clean,
12461246
&& $token[0] === T_STRING
12471247
&& isset($tokens[($stackPtr + 1)]) === true
12481248
&& $tokens[($stackPtr + 1)] === ':'
1249-
&& $tokens[($stackPtr - 1)][0] !== T_PAAMAYIM_NEKUDOTAYIM
1249+
&& (is_array($tokens[($stackPtr - 1)]) === false
1250+
|| $tokens[($stackPtr - 1)][0] !== T_PAAMAYIM_NEKUDOTAYIM)
12501251
) {
12511252
$stopTokens = [
12521253
T_CASE => true,

0 commit comments

Comments
 (0)