Skip to content

Commit bbc6046

Browse files
committed
Revert InnerList and OuterList named constructors names
1 parent d244ee4 commit bbc6046

File tree

10 files changed

+50
-54
lines changed

10 files changed

+50
-54
lines changed

CHANGELOG.md

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,13 @@ All Notable changes to `bakame/http-strucured-fields` will be documented in this
66

77
### Added
88

9-
- `Item::fromTimestamp`, `Item::fromDateFormat` to improve item instantiation with dates.
9+
- `Item::fromTimestamp`, `Item::fromDateFormat`, `Item::fromDateString` to improve item instantiation with dates.
1010
- `ParameterAccess::parameter` to ease parameter members value access.
11-
- `InnerList::fromAssociativeParameters`
12-
- `InnerList::fromPairParameters`
11+
- `InnerList::fromAssociativeParameters`, `InnerList::fromPairParameters` to improve item instantiation with parameters.
1312
- **[BC Break]** `ParameterAccess::withoutAllParameters` is renamed `ParameterAccess::withoutAnyParameter`.
1413
- **[BC Break]** `OrderedList` is renamed `OuterList`.
1514
- **[BC Break]** `MemberContainer::remove` methods get added to the interface.
1615
- **[BC Break]** `MemberContainer::keys` method added to the interface.
17-
- **[BC Break]** `InnerList::from` is renamed `InnerList::fromMembers`.
18-
- **[BC Break]** `OuterList::from` is renamed `OuterList::fromMembers`.
1916

2017
### Fixed
2118

@@ -35,11 +32,9 @@ All Notable changes to `bakame/http-strucured-fields` will be documented in this
3532

3633
- **[BC Break]** `OrderedList` is removed, use `OuterList` instead.
3734
- **[BC Break]** `ParameterAccess::withoutAllParameters` is removed, use `ParameterAccess::withoutAnyParameters` instead.
38-
- **[BC Break]** remove the `$parameters` argument from all `Item` named constuctore except from `Item::from`.
39-
- **[BC Break]** remove `InnerList::fromList`, use `InnerList::from` instead.
35+
- **[BC Break]** remove the `$parameters` argument from all `Item` named constuctors except from `Item::from`.
36+
- **[BC Break]** remove `InnerList::fromList`, use `InnerList::fromAssociativeParameters` or `InnerList::fromPairParameters` instead.
4037
- **[BC Break]** remove `OuterList::fromList`, use `OuterList::from` instead.
41-
- **[BC Break]** remove `InnerList::from` use `InnerList::fromMembers`.
42-
- **[BC Break]** remove `OuterList::from` use `OuterList::fromMembers`.
4338
-
4439
## [0.7.0] - 2023-02-06
4540

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ To Create `OuterList` and `InnerList` instances you can use the `fromMembers` na
180180
use Bakame\Http\StructuredFields\InnerList;
181181
use Bakame\Http\StructuredFields\Item;
182182

183-
$list = InnerList::fromMembers(
183+
$list = InnerList::from(
184184
Item::fromDecodedByteSequence('Hello World'),
185185
42.0,
186186
42
@@ -195,7 +195,7 @@ Once again, builder methods exist on both classes to ease container construction
195195
use Bakame\Http\StructuredFields\InnerList;
196196
use Bakame\Http\StructuredFields\Item;
197197

198-
$list = InnerList::fromMembers()
198+
$list = InnerList::from()
199199
->unshift('42')
200200
->push(42)
201201
->insert(1, 42.0)

phpstan.neon

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,5 @@ parameters:
88
paths:
99
- src
1010
ignoreErrors:
11+
- '#it_fails_to_create_an_item_from_an_array_of_pairs\(\)#'
1112
reportUnmatchedIgnoredErrors: true

src/Dictionary.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ private static function filterMember(iterable|StructuredField|Token|ByteSequence
5151
return match (true) {
5252
($member instanceof MemberList && $member instanceof ParameterAccess),
5353
$member instanceof Value => $member,
54-
is_iterable($member) => InnerList::fromMembers(...$member),
54+
is_iterable($member) => InnerList::from(...$member),
5555
default => Item::from($member),
5656
};
5757
}

src/InnerList.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ private static function filterMember(StructuredField|Token|ByteSequence|DateTime
4646
/**
4747
* Returns a new instance.
4848
*/
49-
public static function fromMembers(Value|Token|ByteSequence|DateTimeInterface|Stringable|string|int|float|bool ...$members): static
49+
public static function from(Value|Token|ByteSequence|DateTimeInterface|Stringable|string|int|float|bool ...$members): static
5050
{
5151
return new self(Parameters::create(), $members);
5252
}

src/InnerListTest.php

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public function it_can_add_or_remove_members(): void
3030
{
3131
$stringItem = Item::from('helloWorld');
3232
$booleanItem = Item::from(true);
33-
$instance = InnerList::fromMembers($stringItem, $booleanItem);
33+
$instance = InnerList::from($stringItem, $booleanItem);
3434

3535
self::assertCount(2, $instance);
3636
self::assertTrue($instance->has(1));
@@ -60,7 +60,7 @@ public function it_can_add_or_remove_members(): void
6060
#[Test]
6161
public function it_can_unshift_insert_and_replace(): void
6262
{
63-
$container = InnerList::fromMembers()
63+
$container = InnerList::from()
6464
->unshift('42')
6565
->push(42)
6666
->insert(1, 42.0)
@@ -75,7 +75,7 @@ public function it_can_unshift_insert_and_replace(): void
7575
#[Test]
7676
public function it_returns_the_same_object_if_nothing_is_changed(): void
7777
{
78-
$container = InnerList::fromMembers(42, 'forty-two');
78+
$container = InnerList::from(42, 'forty-two');
7979

8080
$sameContainer = $container
8181
->unshift()
@@ -90,21 +90,21 @@ public function it_fails_to_replace_invalid_index(): void
9090
{
9191
$this->expectException(InvalidOffset::class);
9292

93-
InnerList::fromMembers()->replace(0, ByteSequence::fromDecoded('Hello World'));
93+
InnerList::from()->replace(0, ByteSequence::fromDecoded('Hello World'));
9494
}
9595

9696
#[Test]
9797
public function it_fails_to_insert_at_an_invalid_index(): void
9898
{
9999
$this->expectException(InvalidOffset::class);
100100

101-
InnerList::fromMembers()->insert(3, ByteSequence::fromDecoded('Hello World'));
101+
InnerList::from()->insert(3, ByteSequence::fromDecoded('Hello World'));
102102
}
103103

104104
#[Test]
105105
public function it_fails_to_return_an_member_with_invalid_index(): void
106106
{
107-
$instance = InnerList::fromMembers();
107+
$instance = InnerList::from();
108108

109109
self::assertFalse($instance->has(3));
110110

@@ -127,7 +127,7 @@ public function it_fails_to_access_unknown_parameter_values(): void
127127
{
128128
$this->expectException(StructuredFieldError::class);
129129

130-
InnerList::fromMembers(false)->parameters()->get('bar')->value();
130+
InnerList::from(false)->parameters()->get('bar')->value();
131131
}
132132

133133
#[Test]
@@ -158,29 +158,29 @@ public function it_fails_to_insert_unknown_index_via_the_array_access_interface(
158158
{
159159
$this->expectException(StructuredFieldError::class);
160160

161-
InnerList::fromMembers()->insert(0, Item::from(42.0));
161+
InnerList::from()->insert(0, Item::from(42.0));
162162
}
163163

164164
#[Test]
165165
public function it_returns_the_same_object_if_no_member_is_removed(): void
166166
{
167-
self::assertCount(0, InnerList::fromMembers()->remove(0));
167+
self::assertCount(0, InnerList::from()->remove(0));
168168
}
169169

170170
#[Test]
171171
public function it_fails_to_fetch_an_value_using_an_integer(): void
172172
{
173173
$this->expectException(InvalidOffset::class);
174174

175-
InnerList::fromMembers()->get('zero');
175+
InnerList::from()->get('zero');
176176
}
177177

178178
#[Test]
179179
public function it_can_access_the_item_value(): void
180180
{
181181
$token = Token::fromString('token');
182182
$input = ['foobar', 0, false, $token];
183-
$structuredField = InnerList::fromMembers(...$input);
183+
$structuredField = InnerList::from(...$input);
184184

185185
self::assertFalse($structuredField->get(2)->value());
186186
self::assertEquals($token, $structuredField->get(-1)->value());
@@ -223,7 +223,7 @@ public function it_can_create_via_parameters_access_methods_a_new_object(): void
223223
#[Test]
224224
public function it_implements_the_array_access_interface(): void
225225
{
226-
$structuredField = InnerList::fromMembers('foobar', 'foobar', 'zero', 0);
226+
$structuredField = InnerList::from('foobar', 'foobar', 'zero', 0);
227227

228228
self::assertInstanceOf(Item::class, $structuredField->get(0));
229229
self::assertInstanceOf(Item::class, $structuredField[0]);
@@ -236,22 +236,22 @@ public function it_forbids_removing_members_using_the_array_access_interface():
236236
{
237237
$this->expectException(LogicException::class);
238238

239-
unset(InnerList::fromMembers('foobar', 'foobar', 'zero', 0)[0]);
239+
unset(InnerList::from('foobar', 'foobar', 'zero', 0)[0]);
240240
}
241241

242242
#[Test]
243243
public function it_forbids_adding_members_using_the_array_access_interface(): void
244244
{
245245
$this->expectException(LogicException::class);
246246

247-
InnerList::fromMembers('foobar', 'foobar', 'zero', 0)[0] = Item::from(false);
247+
InnerList::from('foobar', 'foobar', 'zero', 0)[0] = Item::from(false);
248248
}
249249

250250

251251
#[Test]
252252
public function it_can_returns_the_container_member_keys(): void
253253
{
254-
$instance = InnerList::fromMembers();
254+
$instance = InnerList::from();
255255

256256
self::assertSame([], $instance->keys());
257257

@@ -260,7 +260,7 @@ public function it_can_returns_the_container_member_keys(): void
260260

261261
self::assertSame([0, 1], $newInstance->keys());
262262

263-
$container = InnerList::fromMembers()
263+
$container = InnerList::from()
264264
->unshift('42')
265265
->push(42)
266266
->insert(1, 42.0)

src/ItemTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -315,16 +315,16 @@ public function it_can_create_an_item_from_a_array_of_pairs(): void
315315
self::assertEquals($instance3, $instance1);
316316
}
317317

318+
#[Test]
319+
#[DataProvider('invalidPairProvider')]
318320
/**
319321
* @param array<mixed> $pair
320322
*/
321-
#[Test]
322-
#[DataProvider('invalidPairProvider')]
323323
public function it_fails_to_create_an_item_from_an_array_of_pairs(array $pair): void
324324
{
325325
$this->expectException(SyntaxError::class);
326326

327-
Item::fromPair($pair); /* @phpstan-ignore-line */
327+
Item::fromPair($pair); // @phpstan-ignore-line
328328
}
329329

330330
/**

src/OuterList.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,15 +45,15 @@ private static function filterMember(iterable|StructuredField|Token|ByteSequence
4545
return match (true) {
4646
($member instanceof MemberList && $member instanceof ParameterAccess),
4747
$member instanceof Value => $member,
48-
is_iterable($member) => InnerList::fromMembers(...$member),
48+
is_iterable($member) => InnerList::from(...$member),
4949
default => Item::from($member),
5050
};
5151
}
5252

5353
/**
5454
* @param StructuredField|iterable<Value|DataType>|DataType ...$members
5555
*/
56-
public static function fromMembers(iterable|StructuredField|Token|ByteSequence|DateTimeInterface|Stringable|string|int|float|bool ...$members): self
56+
public static function from(iterable|StructuredField|Token|ByteSequence|DateTimeInterface|Stringable|string|int|float|bool ...$members): self
5757
{
5858
return new self(...$members);
5959
}
@@ -65,7 +65,7 @@ public static function fromMembers(iterable|StructuredField|Token|ByteSequence|D
6565
*/
6666
public static function fromHttpValue(Stringable|string $httpValue): self
6767
{
68-
return self::fromMembers(...array_map(
68+
return self::from(...array_map(
6969
fn (mixed $value) => is_array($value) ? InnerList::fromAssociativeParameters($value[1], ...$value[0]) : $value,
7070
Parser::parseList($httpValue)
7171
));

0 commit comments

Comments
 (0)