From 6a07757b9a03bd31bd89a62e698b4b6d6abc03ce Mon Sep 17 00:00:00 2001 From: Matthew Brown Date: Tue, 8 Oct 2019 22:41:23 -0400 Subject: [PATCH] Fix tests --- src/Psalm/Internal/Analyzer/TypeAnalyzer.php | 7 ++++++- tests/ArrayAssignmentTest.php | 2 +- tests/FunctionCallTest.php | 4 ++-- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/Psalm/Internal/Analyzer/TypeAnalyzer.php b/src/Psalm/Internal/Analyzer/TypeAnalyzer.php index 1f196b926..aac2b815c 100644 --- a/src/Psalm/Internal/Analyzer/TypeAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/TypeAnalyzer.php @@ -32,6 +32,7 @@ use Psalm\Type\Atomic\TLiteralString; use Psalm\Type\Atomic\TMixed; use Psalm\Type\Atomic\TNamedObject; use Psalm\Type\Atomic\TNever; +use Psalm\Type\Atomic\TNonEmptyArray; use Psalm\Type\Atomic\TNonEmptyList; use Psalm\Type\Atomic\TNull; use Psalm\Type\Atomic\TNumeric; @@ -1958,7 +1959,11 @@ class TypeAnalyzer } 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; diff --git a/tests/ArrayAssignmentTest.php b/tests/ArrayAssignmentTest.php index 33557ef98..f7b3c0c2d 100644 --- a/tests/ArrayAssignmentTest.php +++ b/tests/ArrayAssignmentTest.php @@ -812,7 +812,7 @@ class ArrayAssignmentTest extends TestCase $a_keys = array_keys($a);', 'assertions' => [ '$a' => 'array{0: string, 1: int}', - '$a_values' => 'list', + '$a_values' => 'non-empty-list', '$a_keys' => 'list', ], ], diff --git a/tests/FunctionCallTest.php b/tests/FunctionCallTest.php index 523f3043f..a4ac323d5 100644 --- a/tests/FunctionCallTest.php +++ b/tests/FunctionCallTest.php @@ -215,8 +215,8 @@ class FunctionCallTest extends TestCase $b = array_values(["a" => 1, "b" => 2]); $c = array_values(["a" => "hello", "b" => "jello"]);', 'assertions' => [ - '$b' => 'list', - '$c' => 'list', + '$b' => 'non-empty-list', + '$c' => 'non-empty-list', ], ], 'arrayCombine' => [