From 50df2868f24e3686b0674314fe20f6eacb1c3901 Mon Sep 17 00:00:00 2001 From: Guuzen Date: Sun, 6 Oct 2019 22:28:41 +0300 Subject: [PATCH] Fix issue #2201 (#2212) --- .../Internal/Stubs/CoreGenericFunctions.php | 20 ++++++++----------- tests/FunctionCallTest.php | 20 +++++++++++++++++++ 2 files changed, 28 insertions(+), 12 deletions(-) diff --git a/src/Psalm/Internal/Stubs/CoreGenericFunctions.php b/src/Psalm/Internal/Stubs/CoreGenericFunctions.php index 81072aa79..ff93935a5 100644 --- a/src/Psalm/Internal/Stubs/CoreGenericFunctions.php +++ b/src/Psalm/Internal/Stubs/CoreGenericFunctions.php @@ -45,13 +45,12 @@ function array_unique(array $arr, int $sort_flags = 0) * * @param array $arr * @param array $arr2 - * @param array|null $arr3 - * @param array|null $arr4 + * @param array ...$arr3 * * @return array * @psalm-pure */ -function array_intersect(array $arr, array $arr2, array $arr3 = null, array $arr4 = null) +function array_intersect(array $arr, array $arr2, array ...$arr3) { } @@ -61,13 +60,12 @@ function array_intersect(array $arr, array $arr2, array $arr3 = null, array $arr * * @param array $arr * @param array $arr2 - * @param array|null $arr3 - * @param array|null $arr4 + * @param array ...$arr3 * * @return array * @psalm-pure */ -function array_intersect_key(array $arr, array $arr2, array $arr3 = null, array $arr4 = null) +function array_intersect_key(array $arr, array $arr2, array ...$arr3) { } @@ -92,13 +90,12 @@ function array_combine(array $arr, array $arr2) * * @param array $arr * @param array $arr2 - * @param array|null $arr3 - * @param array|null $arr4 + * @param array ...$arr3 * * @return array * @psalm-pure */ -function array_diff(array $arr, array $arr2, array $arr3 = null, array $arr4 = null) +function array_diff(array $arr, array $arr2, array ...$arr3) { } @@ -108,13 +105,12 @@ function array_diff(array $arr, array $arr2, array $arr3 = null, array $arr4 = n * * @param array $arr * @param array $arr2 - * @param array|null $arr3 - * @param array|null $arr4 + * @param array ...$arr3 * * @return array * @psalm-pure */ -function array_diff_key(array $arr, array $arr2, array $arr3 = null, array $arr4 = null) +function array_diff_key(array $arr, array $arr2, array ...$arr3) { } diff --git a/tests/FunctionCallTest.php b/tests/FunctionCallTest.php index 4a18f731f..3543dfcdb 100644 --- a/tests/FunctionCallTest.php +++ b/tests/FunctionCallTest.php @@ -266,6 +266,16 @@ class FunctionCallTest extends TestCase '$d' => 'array', ], ], + 'arrayDiffIsVariadic' => [ + ' [], + ], + 'arrayDiffKeyIsVariadic' => [ + ' [], + ], 'arrayPopMixed' => [ ' 'array', ], ], + 'arrayIntersectIsVariadic' => [ + ' [], + ], + 'arrayIntersectKeyIsVariadic' => [ + ' [], + ], 'arrayReduce' => [ '