Skip to content

Commit

Permalink
Tokenizer: fix nullable type tokenization with namespace operator
Browse files Browse the repository at this point in the history
The `namespace` keyword as an operator is perfectly valid to be used as part of a type declaration.

This usage was so far not supported in the tokenizer for the determination whether a `?` is a nullable type token or a ternary.

Fixed now.
  • Loading branch information
jrfnl committed Sep 2, 2020
1 parent f378d2a commit 1c59b29
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/Tokenizers/PHP.php
Original file line number Diff line number Diff line change
Expand Up @@ -1149,6 +1149,7 @@ protected function tokenize($string)

if ($tokenType === T_STRING
|| $tokenType === T_ARRAY
|| $tokenType === T_NAMESPACE
|| $tokenType === T_NS_SEPARATOR
) {
$lastRelevantNonEmpty = $tokenType;
Expand Down Expand Up @@ -1382,6 +1383,7 @@ function return types. We want to keep the parenthesis map clean,
T_CALLABLE => T_CALLABLE,
T_SELF => T_SELF,
T_PARENT => T_PARENT,
T_NAMESPACE => T_NAMESPACE,
T_NS_SEPARATOR => T_NS_SEPARATOR,
];

Expand Down

0 comments on commit 1c59b29

Please sign in to comment.