From 1cc13bdeebd0f1151451256d070cc2bd392be87c Mon Sep 17 00:00:00 2001 From: Matthew Brown Date: Fri, 6 Oct 2017 23:35:16 -0400 Subject: [PATCH] Prevent TNamedObject from having a leading slash --- src/Psalm/Checker/FunctionLikeChecker.php | 5 ----- src/Psalm/Type/Atomic/TNamedObject.php | 4 ++++ 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/Psalm/Checker/FunctionLikeChecker.php b/src/Psalm/Checker/FunctionLikeChecker.php index d771abc19..a5c6eba33 100644 --- a/src/Psalm/Checker/FunctionLikeChecker.php +++ b/src/Psalm/Checker/FunctionLikeChecker.php @@ -1152,11 +1152,6 @@ abstract class FunctionLikeChecker extends SourceChecker implements StatementsSo $return_type_tokens = Type::tokenize($return_type); foreach ($return_type_tokens as $i => &$return_type_token) { - if ($return_type_token[0] === '\\') { - $return_type_token = substr($return_type_token, 1); - continue; - } - if (in_array($return_type_token, ['<', '>', '|', '?', ',', '{', '}', ':'], true)) { continue; } diff --git a/src/Psalm/Type/Atomic/TNamedObject.php b/src/Psalm/Type/Atomic/TNamedObject.php index 4d148a6a0..ef66f1e67 100644 --- a/src/Psalm/Type/Atomic/TNamedObject.php +++ b/src/Psalm/Type/Atomic/TNamedObject.php @@ -20,6 +20,10 @@ class TNamedObject extends Atomic */ public function __construct($value) { + if ($value[0] === '\\') { + $value = substr($value, 1); + } + $this->value = $value; }