Skip to content

Commit 6ac3a01

Browse files
committed
Improve PHPStam docblocks
1 parent c0ff7d3 commit 6ac3a01

File tree

5 files changed

+27
-20
lines changed

5 files changed

+27
-20
lines changed

src/Dictionary.php

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
use function is_array;
1515

1616
/**
17+
* @phpstan-type DataType ByteSequence|Token|bool|int|float|string
1718
* @implements OrderedMap<string, Item|InnerList<int, Item>>
1819
*/
1920
final class Dictionary implements OrderedMap
@@ -22,7 +23,7 @@ final class Dictionary implements OrderedMap
2223
private array $members = [];
2324

2425
/**
25-
* @param iterable<string, InnerList<array-key, Item>|Item|ByteSequence|Token|bool|int|float|string> $members
26+
* @param iterable<string, InnerList<int, Item>|Item|DataType> $members
2627
*/
2728
private function __construct(iterable $members = [])
2829
{
@@ -37,7 +38,7 @@ private function __construct(iterable $members = [])
3738
* its keys represent the dictionary entry key
3839
* its values represent the dictionary entry value
3940
*
40-
* @param iterable<string, InnerList<int, Item>|Item|ByteSequence|Token|bool|int|float|string> $members
41+
* @param iterable<string, InnerList<int, Item>|Item|DataType> $members
4142
*/
4243
public static function fromAssociative(iterable $members = []): self
4344
{
@@ -51,7 +52,7 @@ public static function fromAssociative(iterable $members = []): self
5152
* the first member represents the instance entry key
5253
* the second member represents the instance entry value
5354
*
54-
* @param OrderedMap<string, Item|InnerList<int, Item>>|iterable<array{0:string, 1:InnerList<int, Item>|Item|ByteSequence|Token|bool|int|float|string}> $pairs
55+
* @param OrderedMap<string, Item|InnerList<int, Item>>|iterable<array{0:string, 1:InnerList<int, Item>|Item|DataType}> $pairs
5556
*/
5657
public static function fromPairs(OrderedMap|iterable $pairs = []): self
5758
{
@@ -346,7 +347,7 @@ public function mergeAssociative(iterable ...$others): self
346347
/**
347348
* Merges multiple instances using iterable pairs.
348349
*
349-
* @param OrderedMap<string, Item|InnerList<int, Item>>|iterable<array{0:string, 1:InnerList<int, Item>|Item|ByteSequence|Token|bool|int|float|string}> ...$others
350+
* @param OrderedMap<string, Item|InnerList<int, Item>>|iterable<array{0:string, 1:InnerList<int, Item>|Item|DataType}> ...$others
350351
*/
351352
public function mergePairs(OrderedMap|iterable ...$others): self
352353
{
@@ -384,7 +385,7 @@ public function offsetUnset(mixed $offset): void
384385
}
385386

386387
/**
387-
* @param InnerList<int, Item>|Item|ByteSequence|Token|bool|int|float|string $value
388+
* @param InnerList<int, Item>|Item|DataType $value
388389
*/
389390
public function offsetSet(mixed $offset, mixed $value): void
390391
{

src/InnerList.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
use function count;
1414

1515
/**
16+
* @phpstan-type DataType ByteSequence|Token|bool|int|float|string
1617
* @implements MemberList<int, Item>
1718
*/
1819
final class InnerList implements MemberList, ParameterAccess
@@ -33,8 +34,8 @@ public static function from(Item|ByteSequence|Token|bool|int|float|string ...$me
3334
}
3435

3536
/**
36-
* @param iterable<Item|ByteSequence|Token|bool|int|float|string> $members
37-
* @param iterable<array-key, Item|ByteSequence|Token|bool|int|float|string> $parameters
37+
* @param iterable<Item|DataType> $members
38+
* @param iterable<string, Item|DataType> $parameters
3839
*/
3940
public static function fromList(iterable $members = [], iterable $parameters = []): self
4041
{
@@ -255,7 +256,7 @@ public function offsetUnset($offset): void
255256
}
256257

257258
/**
258-
* @param Item|ByteSequence|Token|bool|int|float|string $value the member to add
259+
* @param Item|DataType $value the member to add
259260
*
260261
* @see ::push
261262
* @see ::replace

src/Item.php

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@
2020
use function substr;
2121
use function trim;
2222

23+
/**
24+
* @phpstan-type DataType ByteSequence|Token|bool|int|float|string
25+
*/
2326
final class Item implements StructuredField, ParameterAccess
2427
{
2528
private function __construct(
@@ -30,8 +33,8 @@ private function __construct(
3033

3134
/**
3235
* @param array{
33-
* 0:Token|ByteSequence|int|float|string|bool,
34-
* 1?:OrderedMap<string, Item>|iterable<array{0:string, 1:Item|ByteSequence|Token|bool|int|float|string}>
36+
* 0:DataType,
37+
* 1?:OrderedMap<string, Item>|iterable<array{0:string, 1:Item|DataType}>
3538
* } $pair
3639
*/
3740
public static function fromPair(array $pair): self
@@ -51,7 +54,7 @@ public static function fromPair(array $pair): self
5154
/**
5255
* Returns a new instance from a value type and an iterable of key-value parameters.
5356
*
54-
* @param iterable<string,Item|ByteSequence|Token|bool|int|float|string> $parameters
57+
* @param iterable<string,Item|DataType> $parameters
5558
*/
5659
public static function from(
5760
Token|ByteSequence|int|float|string|bool $value,
@@ -68,7 +71,7 @@ public static function from(
6871
/**
6972
* Returns a new instance from an encoded byte sequence and an iterable of key-value parameters.
7073
*
71-
* @param iterable<string,Item|ByteSequence|Token|bool|int|float|string> $parameters
74+
* @param iterable<string,Item|DataType> $parameters
7275
*/
7376
public static function fromEncodedByteSequence(string|Stringable $value, iterable $parameters = []): self
7477
{
@@ -78,7 +81,7 @@ public static function fromEncodedByteSequence(string|Stringable $value, iterabl
7881
/**
7982
* Returns a new instance from a decoded byte sequence and an iterable of key-value parameters.
8083
*
81-
* @param iterable<string,Item|ByteSequence|Token|bool|int|float|string> $parameters
84+
* @param iterable<string,Item|DataType> $parameters
8285
*/
8386
public static function fromDecodedByteSequence(string|Stringable $value, iterable $parameters = []): self
8487
{

src/OrderedList.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
use function is_array;
1616

1717
/**
18+
* @phpstan-type DataType ByteSequence|Token|bool|int|float|string
1819
* @implements MemberList<int, Item|MemberList<int, Item>>
1920
*/
2021
final class OrderedList implements MemberList
@@ -28,7 +29,7 @@ private function __construct(Item|InnerList ...$members)
2829
}
2930

3031
/**
31-
* @param MemberList<int, Item>|Item|ByteSequence|Token|bool|int|float|string ...$members
32+
* @param MemberList<int, Item>|Item|DataType ...$members
3233
*
3334
* @return static
3435
*/
@@ -38,7 +39,7 @@ public static function from(MemberList|Item|ByteSequence|Token|bool|int|float|st
3839
}
3940

4041
/**
41-
* @param iterable<MemberList<int, Item>|Item|ByteSequence|Token|bool|int|float|string> $members
42+
* @param iterable<MemberList<int, Item>|Item|DataType> $members
4243
*/
4344
public static function fromList(iterable $members = []): self
4445
{
@@ -286,7 +287,7 @@ public function offsetUnset($offset): void
286287

287288
/**
288289
* @param int|null $offset
289-
* @param MemberList<int, Item>|Item|ByteSequence|Token|bool|int|float|string $value the member to add
290+
* @param MemberList<int, Item>|Item|DataType $value the member to add
290291
*
291292
* @see ::push
292293
* @see ::replace

src/Parameters.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
use function trim;
1818

1919
/**
20+
* @phpstan-type DataType ByteSequence|Token|bool|int|float|string
2021
* @implements OrderedMap<string, Item>
2122
*/
2223
final class Parameters implements OrderedMap
@@ -25,7 +26,7 @@ final class Parameters implements OrderedMap
2526
private array $members = [];
2627

2728
/**
28-
* @param iterable<array-key, Item|Token|ByteSequence|float|int|bool|string> $members
29+
* @param iterable<string, Item|DataType> $members
2930
*/
3031
private function __construct(iterable $members = [])
3132
{
@@ -362,7 +363,7 @@ public function prepend(string $key, StructuredField|ByteSequence|Token|bool|int
362363
/**
363364
* Merges multiple instances using iterable associative structures.
364365
*
365-
* @param iterable<string, Item|Token|ByteSequence|float|int|bool|string> ...$others
366+
* @param iterable<string, Item|DataType> ...$others
366367
*/
367368
public function mergeAssociative(iterable ...$others): self
368369
{
@@ -376,7 +377,7 @@ public function mergeAssociative(iterable ...$others): self
376377
/**
377378
* Merge multiple instances using iterable pairs.
378379
*
379-
* @param OrderedMap<string, Item>|iterable<array{0:string, 1:Item|ByteSequence|Token|bool|int|float|string}> ...$others
380+
* @param OrderedMap<string, Item>|iterable<array{0:string, 1:Item|DataType}> ...$others
380381
*/
381382
public function mergePairs(OrderedMap|iterable ...$others): self
382383
{
@@ -413,7 +414,7 @@ public function offsetUnset($offset): void
413414

414415
/**
415416
* @param string|null $offset
416-
* @param Item|ByteSequence|Token|bool|int|float|string $value the member value
417+
* @param Item|DataType $value the member value
417418
*/
418419
public function offsetSet(mixed $offset, mixed $value): void
419420
{

0 commit comments

Comments
 (0)