-
Notifications
You must be signed in to change notification settings - Fork 462
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Prevent redundant messages about missing iterable types in conditiona…
…l target/subject
- Loading branch information
1 parent
4d584d1
commit 21e9087
Showing
5 changed files
with
68 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<?php declare(strict_types = 1); | ||
|
||
namespace Bug7215; | ||
|
||
use function PHPStan\Testing\assertType; | ||
|
||
/** | ||
* @template T | ||
* @param array<T,mixed> $array | ||
* @return (T is int ? ($array is non-empty-array ? non-empty-list<numeric-string> : list<numeric-string>) : ($array is non-empty-array ? non-empty-list<numeric-string> : list<string>)) | ||
*/ | ||
function keysAsString(array $array): array | ||
{ | ||
$keys = []; | ||
|
||
foreach ($array as $k => $_) { | ||
$keys[] = (string)$k; | ||
} | ||
|
||
return $keys; | ||
} | ||
|
||
function () { | ||
assertType('array<int, numeric-string>', keysAsString([])); | ||
assertType('non-empty-array<int, numeric-string>', keysAsString(['' => ''])); | ||
}; |