Skip to content

Commit ec236a5

Browse files
committed
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 2b8c1b3 commit ec236a5

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
@@ -1441,7 +1441,8 @@ function return types. We want to keep the parenthesis map clean,
14411441
&& $token[0] === T_STRING
14421442
&& isset($tokens[($stackPtr + 1)]) === true
14431443
&& $tokens[($stackPtr + 1)] === ':'
1444-
&& $tokens[($stackPtr - 1)][0] !== T_PAAMAYIM_NEKUDOTAYIM
1444+
&& (is_array($tokens[($stackPtr - 1)]) === false
1445+
|| $tokens[($stackPtr - 1)][0] !== T_PAAMAYIM_NEKUDOTAYIM)
14451446
) {
14461447
$stopTokens = [
14471448
T_CASE => true,

0 commit comments

Comments
 (0)