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

fix: add preserve_keys on array_reverse function

This commit is contained in:
Stéphane Bour 2018-01-04 00:22:50 +01:00 committed by Matthew Brown
parent 87440314c9
commit 9b2cfdc669
2 changed files with 16 additions and 1 deletions

View File

@ -108,9 +108,10 @@ function array_pop(array &$arr) {}
* @template TValue
*
* @param array<TKey, TValue> $arr
* @param bool $preserve_keys
* @return array<TKey, TValue>
*/
function array_reverse(array $arr) {}
function array_reverse(array $arr, bool $preserve_keys = false) {}
/**
* @template TKey

View File

@ -211,6 +211,20 @@ class FunctionCallTest extends TestCase
'$d' => 'array{0:string, 1:string, 2:string, 3:int, 4:int, 5:int}',
],
],
'arrayReverse' => [
'<?php
$d = array_reverse(["a", "b", 1]);',
'assertions' => [
'$d' => 'array<int, int|string>',
],
],
'arrayReversePreserveKey' => [
'<?php
$d = array_reverse(["a", "b", 1], true);',
'assertions' => [
'$d' => 'array<int, int|string>',
],
],
'arrayDiff' => [
'<?php
$d = array_diff(["a" => 5, "b" => 12], [5]);',