Skip to content

Commit

Permalink
Make PHPStan happy
Browse files Browse the repository at this point in the history
  • Loading branch information
nyamsprod committed Dec 23, 2023
1 parent fe4feac commit 074afd2
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 2 additions & 0 deletions phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,6 @@ parameters:
ignoreErrors:
- message: '#it_fails_to_create_an_item_from_an_array_of_pairs\(\)#'
path: tests/ItemTest.php
- message: '#Function http_build_structured_field\(\) has parameter \$data with no value type specified in iterable type iterable.#'
path: src/functions.php
reportUnmatchedIgnoredErrors: true
6 changes: 2 additions & 4 deletions src/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,12 @@ function http_parse_structured_field(string $type, string $httpValue): Structure
*/
function http_build_structured_field(string $type, iterable $data): string /* @phptan-ignore-line */
{
$data = [...$data];

return match ($type) {
'dictionary' => Dictionary::fromPairs($data)->toHttpValue(),
'parameters' => Parameters::fromPairs($data)->toHttpValue(),
'list' => OuterList::fromPairs($data)->toHttpValue(),
'innerlist' => InnerList::fromPair($data)->toHttpValue(), /* @phpstan-ignore-line */
'item' => Item::fromPair($data)->toHttpValue(), /* @phpstan-ignore-line */
'innerlist' => InnerList::fromPair([...$data])->toHttpValue(), /* @phpstan-ignore-line */
'item' => Item::fromPair([...$data])->toHttpValue(), /* @phpstan-ignore-line */
default => throw new OutOfBoundsException('The submitted type "'.$type.'" is unknown or not supported,'), /* @phpstan-ignore-line */
};
}
Expand Down

0 comments on commit 074afd2

Please sign in to comment.