From 6784a90b2ff6a93ad57cd093ef2ccfbe65e1da54 Mon Sep 17 00:00:00 2001 From: Matthew Brown Date: Thu, 21 May 2020 11:29:54 -0400 Subject: [PATCH] Fix #3423 - allow conditional with func_num_args() in namespace --- src/Psalm/Internal/Type/TypeTokenizer.php | 4 ++++ tests/Template/ConditionalReturnTypeTest.php | 15 +++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/src/Psalm/Internal/Type/TypeTokenizer.php b/src/Psalm/Internal/Type/TypeTokenizer.php index 59beae3cf..341f12d05 100644 --- a/src/Psalm/Internal/Type/TypeTokenizer.php +++ b/src/Psalm/Internal/Type/TypeTokenizer.php @@ -443,6 +443,10 @@ class TypeTokenizer continue; } + if ($string_type_token[0] === 'func_num_args()') { + continue; + } + if (isset($type_aliases[$string_type_token[0]])) { $type_alias = $type_aliases[$string_type_token[0]]; diff --git a/tests/Template/ConditionalReturnTypeTest.php b/tests/Template/ConditionalReturnTypeTest.php index b2a7b7864..4f5b2f3fd 100644 --- a/tests/Template/ConditionalReturnTypeTest.php +++ b/tests/Template/ConditionalReturnTypeTest.php @@ -461,6 +461,21 @@ class ConditionalReturnTypeTest extends TestCase '$c' => 'string', ] ], + 'namespaceFuncNumArgs' => [ + '