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

fix return type of "array_combine()" && "array_replace()"

This commit is contained in:
Lars Moelleken 2019-05-05 08:11:52 +02:00 committed by Matthew Brown
parent d4f1a4a75f
commit 0b5680f72f
3 changed files with 14 additions and 6 deletions

View File

@ -393,7 +393,7 @@ return [
'array_rand' => ['int|string|array<int,int>|array<int,string>', 'input'=>'array', 'num_req'=>'int'],
'array_rand\'1' => ['int|string', 'input'=>'array'],
'array_reduce' => ['mixed', 'input'=>'array', 'callback'=>'callable(mixed,mixed):mixed', 'initial='=>'mixed'],
'array_replace' => ['array', 'arr1'=>'array', 'arr2'=>'array', '...args='=>'array'],
'array_replace' => ['?array', 'arr1'=>'array', 'arr2'=>'array', '...args='=>'array'],
'array_replace_recursive' => ['?array', 'arr1'=>'array', 'arr2'=>'array', '...args='=>'array'],
'array_reverse' => ['array', 'input'=>'array', 'preserve='=>'bool'],
'array_search' => ['int|string|false', 'needle'=>'mixed', 'haystack'=>'array', 'strict='=>'bool'],
@ -2139,7 +2139,7 @@ return [
'DOMElement::set_attribute' => ['DomAttribute', 'name'=>'string', 'value'=>'string'],
'DOMElement::set_attribute_node' => ['DomNode', 'attr'=>'DOMNode'],
'DOMElement::setAttribute' => ['DOMAttr|false', 'name'=>'string', 'value'=>'string'],
'DOMElement::setAttributeNode' => ['DOMAttr', 'attr'=>'DOMAttr'],
'DOMElement::setAttributeNode' => ['?DOMAttr', 'attr'=>'DOMAttr'],
'DOMElement::setAttributeNodeNS' => ['DOMAttr', 'attr'=>'DOMAttr'],
'DOMElement::setAttributeNS' => ['void', 'namespaceuri'=>'string', 'qualifiedname'=>'string', 'value'=>'string'],
'DOMElement::setIdAttribute' => ['void', 'name'=>'string', 'isid'=>'bool'],
@ -11244,7 +11244,7 @@ return [
'ReflectionParameter::getDeclaringClass' => ['?ReflectionClass'],
'ReflectionParameter::getDeclaringFunction' => ['ReflectionFunctionAbstract'],
'ReflectionParameter::getDefaultValue' => ['mixed'],
'ReflectionParameter::getDefaultValueConstantName' => ['string'],
'ReflectionParameter::getDefaultValueConstantName' => ['?string'],
'ReflectionParameter::getName' => ['string'],
'ReflectionParameter::getPosition' => ['int'],
'ReflectionParameter::getType' => ['?ReflectionType'],

View File

@ -57,7 +57,7 @@ function array_intersect_key(array $arr, array $arr2, array $arr3 = null, array
*
* @param array<mixed, TKey> $arr
* @param array<mixed, TValue> $arr2
* @return array<TKey, TValue>
* @return array<TKey, TValue>|false
*/
function array_combine(array $arr, array $arr2) {}
@ -126,6 +126,7 @@ function array_search($needle, array $haystack, bool $strict = false) {}
* @param array<mixed,T> $arr
* @param callable(T,T):int $callback
* @param-out array<int,T> $arr
* @return bool
*/
function usort(array &$arr, callable $callback): bool {}
@ -133,7 +134,7 @@ function usort(array &$arr, callable $callback): bool {}
* @psalm-template T
*
* @param array<string, T> $arr
* @return array<string, T>
* @return array<string, T>|false
*/
function array_change_key_case(array $arr, int $case = CASE_LOWER) {}

View File

@ -209,7 +209,14 @@ class FunctionCallTest extends TestCase
'<?php
$c = array_combine(["a", "b", "c"], [1, 2, 3]);',
'assertions' => [
'$c' => 'array<string, int>',
'$c' => 'array<string, int>|false',
],
],
'arrayCombineFalse' => [
'<?php
$c = array_combine(["a", "b"], [1, 2, 3]);',
'assertions' => [
'$c' => 'array<string, int>|false',
],
],
'arrayMerge' => [