1
0
mirror of https://github.com/danog/psalm.git synced 2024-11-26 20:34:47 +01:00

Added array_fill_keys support (#2512)

* Added array_fill_keys support

* Removed unnecessary array_fill_keys phpdoc
This commit is contained in:
Valentin Udaltsov 2019-12-27 16:30:42 +03:00 committed by Matthew Brown
parent 6b81f8c64a
commit 006f788d6a
4 changed files with 22 additions and 2 deletions

View File

@ -1187,7 +1187,6 @@ class ProjectAnalyzer
public function setAllIssuesToFix(): void
{
/** @var array<string, true> $keyed_issues */
$keyed_issues = array_fill_keys(static::getSupportedIssuesToFix(), true);
$this->setIssuesToFix($keyed_issues);

View File

@ -287,7 +287,6 @@ class Pool
// Create an array for the content received on each stream,
// indexed by resource id.
/** @var array<int, string> $content */
$content = array_fill_keys(array_keys($streams), '');
$terminationMessages = [];

View File

@ -217,3 +217,17 @@ function array_key_exists($key, array $search) : bool
function array_merge_recursive(array $arr, array ...$arr2)
{
}
/**
* @psalm-template TKey as array-key
* @psalm-template TValue
*
* @param array<TKey> $keys
* @param TValue $value
*
* @return array<TKey, TValue>
* @psalm-pure
*/
function array_fill_keys(array $keys, $value): array
{
}

View File

@ -2334,6 +2334,14 @@ class FunctionCallTest extends TestCase
);
}'
],
'arrayFillKeys' => [
'<?php
$keys = [1, 2, 3];
$result = array_fill_keys($keys, true);',
'assertions' => [
'$result' => 'array<int, true>',
],
],
];
}