Skip to content

Commit

Permalink
PHP 8.0 | Tokenizer/PHP: bug fix
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
jrfnl committed Jul 23, 2020
1 parent 2b8c1b3 commit ec236a5
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/Tokenizers/PHP.php
Original file line number Diff line number Diff line change
Expand Up @@ -1441,7 +1441,8 @@ function return types. We want to keep the parenthesis map clean,
&& $token[0] === T_STRING
&& isset($tokens[($stackPtr + 1)]) === true
&& $tokens[($stackPtr + 1)] === ':'
&& $tokens[($stackPtr - 1)][0] !== T_PAAMAYIM_NEKUDOTAYIM
&& (is_array($tokens[($stackPtr - 1)]) === false
|| $tokens[($stackPtr - 1)][0] !== T_PAAMAYIM_NEKUDOTAYIM)
) {
$stopTokens = [
T_CASE => true,
Expand Down

0 comments on commit ec236a5

Please sign in to comment.