Skip to content

Commit f79ed2b

Browse files
committed
Fix documentation and internal codebase
1 parent a23b0b9 commit f79ed2b

File tree

5 files changed

+15
-18
lines changed

5 files changed

+15
-18
lines changed

docs/ordered-maps.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ named constructors:
1515

1616
- `fromAssociative` instantiates the container with an iterable construct of associative value;
1717
- `fromPairs` instantiates the container with a list of key-value pairs;
18-
- `new` instantiates the container with no members;
18+
- `create` instantiates the container with no members;
1919

2020
getter methods:
2121

src/Dictionary.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ public static function fromHttpValue(Stringable|string $httpValue): self
9292

9393
public function toHttpValue(): string
9494
{
95-
$formatter = fn (Item|InnerList $member, string $key): string => match (true) {
95+
$formatter = static fn (Item|InnerList $member, string $key): string => match (true) {
9696
$member instanceof Item && true === $member->value() => $key.$member->parameters()->toHttpValue(),
9797
default => $key.'='.$member->toHttpValue(),
9898
};

src/InnerList.php

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -47,15 +47,6 @@ public static function fromList(iterable $members, iterable $parameters = []): s
4747
return $instance;
4848
}
4949

50-
private static function filterMember(StructuredField|Token|ByteSequence|DateTimeInterface|Stringable|string|int|float|bool $member): Item
51-
{
52-
return match (true) {
53-
$member instanceof Item => $member,
54-
$member instanceof StructuredField => throw new InvalidArgument('Expecting a "'.Item::class.'" instance; received a "'.$member::class.'" instead.'),
55-
default => Item::from($member),
56-
};
57-
}
58-
5950
public static function fromHttpValue(Stringable|string $httpValue): self
6051
{
6152
return InnerList::fromList(...Parser::parseInnerList($httpValue));
@@ -100,10 +91,7 @@ public function withParameters(Parameters $parameters): static
10091

10192
public function toHttpValue(): string
10293
{
103-
return '('.implode(' ', array_map(
104-
fn (Item $value): string => $value->toHttpValue(),
105-
$this->members
106-
)).')'.$this->parameters->toHttpValue();
94+
return '('.implode(' ', array_map(fn (Item $value): string => $value->toHttpValue(), $this->members)).')'.$this->parameters->toHttpValue();
10795
}
10896

10997
public function count(): int
@@ -179,6 +167,15 @@ public function push(StructuredField|Token|ByteSequence|DateTimeInterface|String
179167
return $this;
180168
}
181169

170+
private static function filterMember(StructuredField|Token|ByteSequence|DateTimeInterface|Stringable|string|int|float|bool $member): Item
171+
{
172+
return match (true) {
173+
$member instanceof Item => $member,
174+
$member instanceof StructuredField => throw new InvalidArgument('Expecting a "'.Item::class.'" instance; received a "'.$member::class.'" instead.'),
175+
default => Item::from($member),
176+
};
177+
}
178+
182179
/**
183180
* Replace the member associated with the index.
184181
*

src/OrderedList.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ public static function fromHttpValue(Stringable|string $httpValue): self
7171

7272
public function toHttpValue(): string
7373
{
74-
return implode(', ', array_map(fn (InnerList|Item $member): string => $member->toHttpValue(), $this->members));
74+
return implode(', ', array_map(fn (StructuredField $member): string => $member->toHttpValue(), $this->members));
7575
}
7676

7777
public function count(): int

src/Parameters.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,15 +87,15 @@ public static function fromHttpValue(Stringable|string $httpValue): self
8787
$httpValue = trim((string) $httpValue);
8888
[$parameters, $offset] = Parser::parseParameters($httpValue);
8989
if (strlen($httpValue) !== $offset) {
90-
throw new SyntaxError('The HTTP textual representation "'.$httpValue.'" for a paramater contains invalid characters.');
90+
throw new SyntaxError('The HTTP textual representation "'.$httpValue.'" for Parameters contains invalid characters.');
9191
}
9292

9393
return self::fromAssociative($parameters);
9494
}
9595

9696
public function toHttpValue(): string
9797
{
98-
$formatter = fn (Item $member, string $offset): string => match (true) {
98+
$formatter = static fn (Item $member, string $offset): string => match (true) {
9999
true === $member->value() => ';'.$offset,
100100
default => ';'.$offset.'='.$member->toHttpValue(),
101101
};

0 commit comments

Comments
 (0)