Skip to content
Permalink
Browse files

Added array_key_first and array_key_last stubs (#2381)

  • Loading branch information
vudaltsov authored and muglug committed Nov 27, 2019
1 parent 113bf92 commit 4a742f9940dce8a56d5bc1b2f09333f2a03ec148
Showing with 46 additions and 0 deletions.
  1. +26 −0 src/Psalm/Internal/Stubs/CoreGenericFunctions.php
  2. +20 −0 tests/FunctionCallTest.php
@@ -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 @@ public static function Baz($mixed) : string {
'$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 */

0 comments on commit 4a742f9

Please sign in to comment.
You can’t perform that action at this time.