1
0
mirror of https://github.com/danog/psalm.git synced 2025-01-21 21:31:13 +01:00

Fix #2847 - use fully-qualified function name

This commit is contained in:
Brown 2020-02-21 16:44:31 -05:00
parent ae08552f40
commit f4485cc529
2 changed files with 40 additions and 1 deletions

View File

@ -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(

View File

@ -969,6 +969,42 @@ class FunctionTemplateTest extends TestCase
echo (string) $key;
}'
],
'uksortNoNamespace' => [
'<?php
/**
* @template Tk of array-key
* @template Tv
*
* @param array<Tk, Tv> $result
* @param (callable(Tk, Tk): int) $comparator
*
* @preturn array<Tk, Tv>
*/
function sort_by_key(array $result, callable $comparator): array
{
\uksort($result, $comparator);
return $result;
}'
],
'uksortNamespaced' => [
'<?php
namespace Psl\Arr;
/**
* @template Tk of array-key
* @template Tv
*
* @param array<Tk, Tv> $result
* @param (callable(Tk, Tk): int) $comparator
*
* @preturn array<Tk, Tv>
*/
function sort_by_key(array $result, callable $comparator): array
{
\uksort($result, $comparator);
return $result;
}'
],
];
}