Skip to content

Commit

Permalink
Merge branch refs/heads/1.12.x into 2.0.x
Browse files Browse the repository at this point in the history
  • Loading branch information
phpstan-bot committed Sep 20, 2024
2 parents e8027e7 + 06ab320 commit d547ddc
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
8 changes: 8 additions & 0 deletions stubs/arrayFunctions.stub
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,14 @@ function array_reduce(
$three = null
) {}

/**
* @template T of mixed
*
* @param array<T> $array
* @return ($array is non-empty-array ? non-empty-list<T> : list<T>)
*/
function array_values(array $array): array {}

/**
* @template TKey as (int|string)
* @template T
Expand Down
8 changes: 8 additions & 0 deletions tests/PHPStan/Analyser/nsrt/array_values.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,12 @@ public function constantArrayType(): void
);
assertType("array{0?: 'a'|'b'|'c', 1?: 'b'|'c', 2?: 'c'}", array_values($numbers));
}

/**
* @param array<string, non-empty-array<string, int>> $a
*/
public function arrayMap(array $a): void
{
assertType('array<string, non-empty-list<int>>', array_map(array_values(...), $a));
}
}

0 comments on commit d547ddc

Please sign in to comment.