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

Fix #2440 - add support for uasort

This commit is contained in:
Matthew Brown 2019-12-08 21:30:19 -05:00
parent d6a731be73
commit 432c291dd7
2 changed files with 20 additions and 10 deletions

View File

@ -166,6 +166,19 @@ function usort(array &$arr, callable $callback): bool
{
}
/**
* @template TKey
* @template T
*
* @param array<TKey,T> $arr
* @param callable(T,T):int $callback
* @param-out array<TKey,T> $arr
* @psalm-pure
*/
function uasort(array &$arr, callable $callback): bool
{
}
/**
* @psalm-template T
*

View File

@ -550,18 +550,15 @@ class FunctionCallTest extends TestCase
],
'uasort' => [
'<?php
$manifest = ["a" => 1, "b" => 2];
uasort(
$manifest,
function ($a, $b) {
return strcmp($a["parent"],$b["parent"]);
}
$manifest,
function (int $a, int $b) {
return $a > $b ? 1 : -1;
}
);',
'assertions' => [],
'error_levels' => [
'MixedArrayAccess',
'MixedArgument',
'MissingClosureParamType',
'MissingClosureReturnType',
'assertions' => [
'$manifest' => 'array<string, int>'
],
],
'byRefAfterCallable' => [