diff --git a/src/Psalm/Internal/Analyzer/FunctionLikeAnalyzer.php b/src/Psalm/Internal/Analyzer/FunctionLikeAnalyzer.php index 413138075..9689fb33f 100644 --- a/src/Psalm/Internal/Analyzer/FunctionLikeAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/FunctionLikeAnalyzer.php @@ -321,7 +321,10 @@ abstract class FunctionLikeAnalyzer extends SourceAnalyzer } } elseif ($this->function instanceof Function_) { $cased_method_id = $this->function->name->name; - $context->calling_function_id = strtolower($cased_method_id); + $namespace_prefix = $this->getNamespace(); + $context->calling_function_id = strtolower( + ($namespace_prefix !== null ? $namespace_prefix . '\\' : '') . $cased_method_id + ); } else { // Closure if ($storage->return_type) { $closure_return_type = ExpressionAnalyzer::fleshOutType( diff --git a/tests/Template/FunctionTemplateTest.php b/tests/Template/FunctionTemplateTest.php index 13f23b915..eb6b2196c 100644 --- a/tests/Template/FunctionTemplateTest.php +++ b/tests/Template/FunctionTemplateTest.php @@ -969,6 +969,42 @@ class FunctionTemplateTest extends TestCase echo (string) $key; }' ], + 'uksortNoNamespace' => [ + ' $result + * @param (callable(Tk, Tk): int) $comparator + * + * @preturn array + */ + function sort_by_key(array $result, callable $comparator): array + { + \uksort($result, $comparator); + return $result; + }' + ], + 'uksortNamespaced' => [ + ' $result + * @param (callable(Tk, Tk): int) $comparator + * + * @preturn array + */ + function sort_by_key(array $result, callable $comparator): array + { + \uksort($result, $comparator); + return $result; + }' + ], ]; }