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

Make tests a bit more specific

This commit is contained in:
Matt Brown 2018-04-10 15:47:04 -04:00
parent 8faa36c1cf
commit fe46e4e63d
3 changed files with 29 additions and 18 deletions

View File

@ -145,11 +145,11 @@ class IfChecker
$newish_var_ids = array_map(
/**
* @param mixed $_
* @param Type\Union $_
*
* @return true
*/
function ($_) {
function (Type\Union $_) {
return true;
},
array_diff_key(

View File

@ -287,10 +287,10 @@ class CallableTest extends TestCase
'arrayMapVariadicClosureArg' => [
'<?php
$a = array_map(
function(int $type, string ...$args):string {
return "hello";
},
[1, 2, 3]
function(int $type, string ...$args):string {
return "hello";
},
[1, 2, 3]
);',
],
'returnsTypedClosure' => [
@ -440,12 +440,17 @@ class CallableTest extends TestCase
function f(array $ret) : array
{
return array_map(
function (array $row) {
return [
strval($row[0]),
intval($row[1]),
];
}, $ret);
/**
* @param array{0:string,1:string} $row
*/
function (array $row) {
return [
strval($row[0]),
intval($row[1]),
];
},
$ret
);
}',
'assertions' => [],
'error_levels' => ['MissingClosureReturnType'],
@ -459,12 +464,17 @@ class CallableTest extends TestCase
function f(array $ret): array
{
return array_map(
function (array $row): array {
return [
strval($row[0]),
intval($row[1]),
];
}, $ret);
/**
* @param array{0:string,1:string} $row
*/
function (array $row): array {
return [
strval($row[0]),
intval($row[1]),
];
},
$ret
);
}',
],
];

View File

@ -508,6 +508,7 @@ class FunctionCallTest extends TestCase
'assertions' => [],
'error_levels' => [
'MissingClosureParamType',
'MixedTypeCoercion',
],
],
'arrayFilterGoodArgs' => [