mirror of
https://github.com/danog/psalm.git
synced 2024-11-26 20:34:47 +01:00
Added array_key_first and array_key_last stubs (#2381)
This commit is contained in:
parent
113bf921f6
commit
4a742f9940
@ -114,6 +114,32 @@ function key($arr)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* @psalm-template TKey as array-key
|
||||
*
|
||||
* @param array<TKey, mixed> $arr
|
||||
*
|
||||
* @return TKey|null
|
||||
* @psalm-ignore-nullable-return
|
||||
* @psalm-pure
|
||||
*/
|
||||
function array_key_first($arr)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* @psalm-template TKey as array-key
|
||||
*
|
||||
* @param array<TKey, mixed> $arr
|
||||
*
|
||||
* @return TKey|null
|
||||
* @psalm-ignore-nullable-return
|
||||
* @psalm-pure
|
||||
*/
|
||||
function array_key_last($arr)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* @psalm-template T
|
||||
*
|
||||
|
@ -1022,6 +1022,26 @@ class FunctionCallTest extends TestCase
|
||||
'$c' => 'int',
|
||||
],
|
||||
],
|
||||
'array_key_first' => [
|
||||
'<?php
|
||||
$a = ["one" => 1, "two" => 3];
|
||||
$b = array_key_first($a);
|
||||
$c = $a[$b];',
|
||||
'assertions' => [
|
||||
'$b' => 'null|string',
|
||||
'$c' => 'int',
|
||||
],
|
||||
],
|
||||
'array_key_last' => [
|
||||
'<?php
|
||||
$a = ["one" => 1, "two" => 3];
|
||||
$b = array_key_last($a);
|
||||
$c = $a[$b];',
|
||||
'assertions' => [
|
||||
'$b' => 'null|string',
|
||||
'$c' => 'int',
|
||||
],
|
||||
],
|
||||
'explode' => [
|
||||
'<?php
|
||||
/** @var string $string */
|
||||
|
Loading…
Reference in New Issue
Block a user