File tree Expand file tree Collapse file tree 2 files changed +8
-5
lines changed Expand file tree Collapse file tree 2 files changed +8
-5
lines changed Original file line number Diff line number Diff line change 12
12
final class ByteSequence
13
13
{
14
14
private function __construct (
15
- private string $ value
15
+ private readonly string $ value
16
16
) {
17
17
}
18
18
@@ -21,12 +21,15 @@ private function __construct(
21
21
*/
22
22
public static function fromEncoded (Stringable |string $ encodedValue ): self
23
23
{
24
- if (1 !== preg_match ('/^(?<bytes>[a-z\d+\/=]*)$/i ' , (string ) $ encodedValue , $ matches )) {
24
+ $ encodedValue = (string ) $ encodedValue ;
25
+ if (1 !== preg_match ('/^[a-z\d+\/=]*$/i ' , $ encodedValue )) {
25
26
throw new SyntaxError ('Invalid character in byte sequence ' );
26
27
}
27
28
28
- /** @var string $decoded */
29
- $ decoded = base64_decode ($ matches ['bytes ' ], true );
29
+ $ decoded = base64_decode ($ encodedValue , true );
30
+ if (false === $ decoded ) {
31
+ throw new SyntaxError ('Invalid character in byte sequence ' );
32
+ }
30
33
31
34
return new self ($ decoded );
32
35
}
Original file line number Diff line number Diff line change 23
23
final class Item implements StructuredField, ParameterAccess
24
24
{
25
25
private function __construct (
26
- private Token |ByteSequence |int |float |string |bool $ value ,
26
+ private readonly Token |ByteSequence |int |float |string |bool $ value ,
27
27
public readonly Parameters $ parameters
28
28
) {
29
29
}
You can’t perform that action at this time.
0 commit comments