1
0
mirror of https://github.com/danog/psalm.git synced 2024-11-30 04:39:00 +01:00

Fix tests

This commit is contained in:
Matthew Brown 2019-10-08 22:41:23 -04:00
parent d7007c3b76
commit 6a07757b9a
3 changed files with 9 additions and 4 deletions

View File

@ -32,6 +32,7 @@ use Psalm\Type\Atomic\TLiteralString;
use Psalm\Type\Atomic\TMixed; use Psalm\Type\Atomic\TMixed;
use Psalm\Type\Atomic\TNamedObject; use Psalm\Type\Atomic\TNamedObject;
use Psalm\Type\Atomic\TNever; use Psalm\Type\Atomic\TNever;
use Psalm\Type\Atomic\TNonEmptyArray;
use Psalm\Type\Atomic\TNonEmptyList; use Psalm\Type\Atomic\TNonEmptyList;
use Psalm\Type\Atomic\TNull; use Psalm\Type\Atomic\TNull;
use Psalm\Type\Atomic\TNumeric; use Psalm\Type\Atomic\TNumeric;
@ -1958,7 +1959,11 @@ class TypeAnalyzer
} }
if ($input_type_part instanceof TList) { if ($input_type_part instanceof TList) {
$input_type_part = new TArray([Type::getInt(), clone $input_type_part->type_param]); if ($input_type_part instanceof TNonEmptyList) {
$input_type_part = new TNonEmptyArray([Type::getInt(), clone $input_type_part->type_param]);
} else {
$input_type_part = new TArray([Type::getInt(), clone $input_type_part->type_param]);
}
} }
$any_scalar_param_match = false; $any_scalar_param_match = false;

View File

@ -812,7 +812,7 @@ class ArrayAssignmentTest extends TestCase
$a_keys = array_keys($a);', $a_keys = array_keys($a);',
'assertions' => [ 'assertions' => [
'$a' => 'array{0: string, 1: int}', '$a' => 'array{0: string, 1: int}',
'$a_values' => 'list<string|int>', '$a_values' => 'non-empty-list<string|int>',
'$a_keys' => 'list<int>', '$a_keys' => 'list<int>',
], ],
], ],

View File

@ -215,8 +215,8 @@ class FunctionCallTest extends TestCase
$b = array_values(["a" => 1, "b" => 2]); $b = array_values(["a" => 1, "b" => 2]);
$c = array_values(["a" => "hello", "b" => "jello"]);', $c = array_values(["a" => "hello", "b" => "jello"]);',
'assertions' => [ 'assertions' => [
'$b' => 'list<int>', '$b' => 'non-empty-list<int>',
'$c' => 'list<string>', '$c' => 'non-empty-list<string>',
], ],
], ],
'arrayCombine' => [ 'arrayCombine' => [