mirror of
https://github.com/danog/psalm.git
synced 2025-01-21 21:31:13 +01:00
fix stub for array_combine + remove false in PHP8 + improve tests (#5395)
This commit is contained in:
parent
9d840ee87b
commit
1a3ff5676a
@ -66,7 +66,11 @@ function array_intersect_assoc(array $arr, array $arr2, array ...$arr3)
|
||||
* @param array<mixed, TKey> $arr
|
||||
* @param array<mixed, TValue> $arr2
|
||||
*
|
||||
* @return ($arr is non-empty-array ? non-empty-array<TKey, TValue>|false : array<empty, empty>|false)
|
||||
* @return (
|
||||
* PHP_MAJOR_VERSION is 8 ?
|
||||
* ($arr is non-empty-array ? non-empty-array<TKey, TValue> : array<TKey, TValue>) :
|
||||
* ($arr is non-empty-array ? non-empty-array<TKey, TValue>|false : array<TKey, TValue>|false
|
||||
* )
|
||||
* @psalm-ignore-falsable-return
|
||||
* @psalm-pure
|
||||
*/
|
||||
|
@ -159,13 +159,37 @@ class ArrayFunctionCallTest extends TestCase
|
||||
'assertions' => [
|
||||
'$c' => 'false|non-empty-array<string, int>',
|
||||
],
|
||||
'error_levels' => [],
|
||||
'7.4',
|
||||
],
|
||||
'arrayCombineFalse' => [
|
||||
'arrayCombinePHP8' => [
|
||||
'<?php
|
||||
$c = array_combine(["a", "b"], [1, 2, 3]);',
|
||||
'assertions' => [
|
||||
'$c' => 'non-empty-array<string, int>',
|
||||
],
|
||||
'error_levels' => [],
|
||||
'8.0',
|
||||
],
|
||||
'arrayCombineNotMatching' => [
|
||||
'<?php
|
||||
$c = array_combine(["a", "b"], [1, 2, 3]);',
|
||||
'assertions' => [
|
||||
'$c' => 'false|non-empty-array<string, int>',
|
||||
],
|
||||
'error_levels' => [],
|
||||
'7.4',
|
||||
],
|
||||
'arrayCombineDynamicParams' => [
|
||||
'<?php
|
||||
/** @return array<string> */
|
||||
function getStrings(): array{ return []; }
|
||||
/** @return array<int> */
|
||||
function getInts(): array{ return []; }
|
||||
$c = array_combine(getStrings(), getInts());',
|
||||
'assertions' => [
|
||||
'$c' => 'array<string, int>|false',
|
||||
],
|
||||
],
|
||||
'arrayMergeIntArrays' => [
|
||||
'<?php
|
||||
|
Loading…
x
Reference in New Issue
Block a user