Skip to content

Commit 1c59b29

Browse files
committed
Tokenizer: fix nullable type tokenization with namespace operator
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.
1 parent f378d2a commit 1c59b29

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

src/Tokenizers/PHP.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1149,6 +1149,7 @@ protected function tokenize($string)
11491149

11501150
if ($tokenType === T_STRING
11511151
|| $tokenType === T_ARRAY
1152+
|| $tokenType === T_NAMESPACE
11521153
|| $tokenType === T_NS_SEPARATOR
11531154
) {
11541155
$lastRelevantNonEmpty = $tokenType;
@@ -1382,6 +1383,7 @@ function return types. We want to keep the parenthesis map clean,
13821383
T_CALLABLE => T_CALLABLE,
13831384
T_SELF => T_SELF,
13841385
T_PARENT => T_PARENT,
1386+
T_NAMESPACE => T_NAMESPACE,
13851387
T_NS_SEPARATOR => T_NS_SEPARATOR,
13861388
];
13871389

0 commit comments

Comments
 (0)