@@ -34,6 +34,8 @@ private function __construct(
34
34
* in compliance with RFC8941.
35
35
*
36
36
* @see https://www.rfc-editor.org/rfc/rfc8941.html#section-3.3
37
+ *
38
+ * @throws SyntaxError If the HTTP value can not be parsed
37
39
*/
38
40
public static function fromHttpValue (Stringable |string $ httpValue ): self
39
41
{
@@ -54,6 +56,8 @@ public static function fromHttpValue(Stringable|string $httpValue): self
54
56
* Returns a new instance from a value type and an iterable of key-value parameters.
55
57
*
56
58
* @param iterable<string, SfItemInput> $parameters
59
+ *
60
+ * @throws SyntaxError If the value or the parameters are not valid
57
61
*/
58
62
public static function fromAssociative (mixed $ value , iterable $ parameters ): self
59
63
{
@@ -67,13 +71,13 @@ public static function fromAssociative(mixed $value, iterable $parameters): self
67
71
/**
68
72
* @param array{
69
73
* 0:SfItemInput,
70
- * 1? :MemberOrderedMap<string, SfItem>|iterable<array{0:string, 1:SfItemInput}>
74
+ * 1:MemberOrderedMap<string, SfItem>|iterable<array{0:string, 1:SfItemInput}>
71
75
* } $pair
76
+ *
77
+ * @throws SyntaxError If the pair or its content is not valid.
72
78
*/
73
79
public static function fromPair (array $ pair ): self
74
80
{
75
- $ pair [1 ] = $ pair [1 ] ?? [];
76
-
77
81
if (!array_is_list ($ pair )) { /* @phpstan-ignore-line */
78
82
throw new SyntaxError ('The pair must be represented by an array as a list. ' );
79
83
}
@@ -92,11 +96,11 @@ public static function fromPair(array $pair): self
92
96
/**
93
97
* Returns a new bare instance from value.
94
98
*
95
- * @throws SyntaxError If the value is not valid to create a Bare Item .
99
+ * @throws SyntaxError If the value is not valid.
96
100
*/
97
101
public static function new (mixed $ value ): self
98
102
{
99
- return new self (new Value ($ value), Parameters:: new ( ));
103
+ return self :: fromValue (new Value ($ value ));
100
104
}
101
105
102
106
/**
@@ -109,6 +113,8 @@ private static function fromValue(Value $value): self
109
113
110
114
/**
111
115
* Returns a new instance from a string.
116
+ *
117
+ * @throws SyntaxError if the string is invalid
112
118
*/
113
119
public static function fromString (Stringable |string $ value ): self
114
120
{
@@ -117,6 +123,8 @@ public static function fromString(Stringable|string $value): self
117
123
118
124
/**
119
125
* Returns a new instance from an encoded byte sequence and an iterable of key-value parameters.
126
+ *
127
+ * @throws SyntaxError if the sequence is invalid
120
128
*/
121
129
public static function fromEncodedByteSequence (Stringable |string $ value ): self
122
130
{
@@ -125,6 +133,8 @@ public static function fromEncodedByteSequence(Stringable|string $value): self
125
133
126
134
/**
127
135
* Returns a new instance from a decoded byte sequence and an iterable of key-value parameters.
136
+ *
137
+ * @throws SyntaxError if the sequence is invalid
128
138
*/
129
139
public static function fromDecodedByteSequence (Stringable |string $ value ): self
130
140
{
@@ -133,6 +143,8 @@ public static function fromDecodedByteSequence(Stringable|string $value): self
133
143
134
144
/**
135
145
* Returns a new instance from a Token and an iterable of key-value parameters.
146
+ *
147
+ * @throws SyntaxError if the token is invalid
136
148
*/
137
149
public static function fromToken (Stringable |string $ value ): self
138
150
{
@@ -141,6 +153,8 @@ public static function fromToken(Stringable|string $value): self
141
153
142
154
/**
143
155
* Returns a new instance from a timestamp and an iterable of key-value parameters.
156
+ *
157
+ * @throws SyntaxError if the timestamp value is not supported
144
158
*/
145
159
public static function fromTimestamp (int $ timestamp ): self
146
160
{
0 commit comments