-
-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve return types for psalm (#321)
Psalm cannot always infer the types when not defining the CollectionInterface<Key, Value> type. This makes sure that psalm is aware of the implemented interface and the Collection class.
- Loading branch information
Showing
4 changed files
with
42 additions
and
7 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
include __DIR__ . '/../../vendor/autoload.php'; | ||
|
||
use loophp\collection\Collection; | ||
|
||
enum fromIterableAssociateAll: int | ||
{ | ||
case FIFTH = 5; | ||
case FIRST = 1; | ||
case FOURTH = 4; | ||
case SECOND = 2; | ||
case THIRD = 3; | ||
} | ||
|
||
/** | ||
* @psalm-param array<string, int> $array | ||
* | ||
* @phpstan-param array<string, int> $array | ||
*/ | ||
function checklist(array $array): void {} | ||
|
||
checklist(Collection::fromIterable(fromIterableAssociateAll::cases())->associate( | ||
static fn (int $_, fromIterableAssociateAll $item) => $item->value, | ||
static fn (fromIterableAssociateAll $item, int $_) => $item->name, | ||
)->flip()->all(false)); |