From 1c59b291c23c4f43f95356831e1b779aff16e400 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Mon, 31 Aug 2020 00:00:51 +0200 Subject: [PATCH] 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. --- src/Tokenizers/PHP.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Tokenizers/PHP.php b/src/Tokenizers/PHP.php index 5180a5f0e8..085d74990a 100644 --- a/src/Tokenizers/PHP.php +++ b/src/Tokenizers/PHP.php @@ -1149,6 +1149,7 @@ protected function tokenize($string) if ($tokenType === T_STRING || $tokenType === T_ARRAY + || $tokenType === T_NAMESPACE || $tokenType === T_NS_SEPARATOR ) { $lastRelevantNonEmpty = $tokenType; @@ -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, ];