File tree Expand file tree Collapse file tree 6 files changed +23
-11
lines changed Expand file tree Collapse file tree 6 files changed +23
-11
lines changed Original file line number Diff line number Diff line change 48
48
49
49
- name : Run static analysis
50
50
run : composer phpstan
51
- if : ${{ matrix.php == '8.2 ' && matrix.stability == 'prefer-stable'}}
51
+ if : ${{ matrix.php == '8.3 ' && matrix.stability == 'prefer-stable'}}
52
52
53
53
- name : Run Coding style rules
54
54
run : composer phpcs:fix
55
- if : ${{ matrix.php == '8.2 ' && matrix.stability == 'prefer-stable'}}
55
+ if : ${{ matrix.php == '8.3 ' && matrix.stability == 'prefer-stable'}}
Original file line number Diff line number Diff line change @@ -46,12 +46,12 @@ public static function fromEncoded(Stringable|string $encodedValue): self
46
46
return new self ($ value );
47
47
}
48
48
49
- if (1 === preg_match ('/%(?![0-9a-fA-F ]{2})/ ' , $ value )) {
49
+ if (1 === preg_match ('/%(?![0-9a-f ]{2})/ ' , $ value )) {
50
50
throw new SyntaxError ('The string ' .$ value .' contains invalid utf-8 encoded sequence. ' );
51
51
}
52
52
53
53
$ value = (string ) preg_replace_callback (
54
- ',%[A-Fa -f0-9]{2}, ' ,
54
+ ',%[a -f0-9]{2}, ' ,
55
55
fn (array $ matches ): string => rawurldecode ($ matches [0 ]),
56
56
$ value
57
57
);
Original file line number Diff line number Diff line change @@ -447,12 +447,11 @@ private static function extractDisplayString(string $httpValue): array
447
447
448
448
$ octet = substr ($ remainder , 0 , 2 );
449
449
$ offset += 2 ;
450
- $ remainder = substr ($ remainder , 2 );
451
-
452
- if (2 !== strlen ($ octet ) || $ octet !== strtolower ($ octet )) {
450
+ if (1 === preg_match ('/^[0-9a-f]]{2}$/ ' , $ octet )) {
453
451
throw new SyntaxError ("The HTTP textual representation ' $ httpValue' for a DisplayString contains uppercased percent encoding sequence. " );
454
452
}
455
453
454
+ $ remainder = substr ($ remainder , 2 );
456
455
$ output .= $ char .$ octet ;
457
456
}
458
457
Original file line number Diff line number Diff line change @@ -24,8 +24,6 @@ final class ItemTest extends StructuredFieldTestCase
24
24
'number-generated.json ' ,
25
25
'string.json ' ,
26
26
'string-generated.json ' ,
27
- 'token.json ' ,
28
- 'token-generated.json ' ,
29
27
'item.json ' ,
30
28
'date.json ' ,
31
29
];
Original file line number Diff line number Diff line change @@ -143,7 +143,7 @@ public function it_fails_to_parse_an_invalid_http_field_2(): void
143
143
144
144
#[Test]
145
145
#[DataProvider('provideHttpValueForDataType ' )]
146
- public function it_parses_basic_data_type (string $ httpValue , ByteSequence |Token |DateTimeImmutable |string |int |float |bool $ expected ): void
146
+ public function it_parses_basic_data_type (string $ httpValue , ByteSequence |Token |DisplayString | DateTimeImmutable |string |int |float |bool $ expected ): void
147
147
{
148
148
$ field = $ this ->parser ->parseValue ($ httpValue );
149
149
if (is_scalar ($ expected )) {
@@ -197,6 +197,11 @@ public static function provideHttpValueForDataType(): iterable
197
197
'httpValue ' => '?0 ' ,
198
198
'expected ' => false ,
199
199
];
200
+
201
+ yield 'it parses a display string ' => [
202
+ 'httpValue ' => '%"b%c3%a9b%c3%a9" ' ,
203
+ 'expected ' => DisplayString::fromDecoded ('bébé ' ),
204
+ ];
200
205
}
201
206
202
207
#[Test]
@@ -219,6 +224,9 @@ public static function provideInvalidHttpValueForDataType(): array
219
224
['@1_000_000_000_000.0 ' ],
220
225
['-1_000_000_000_000.0 ' ],
221
226
[' ' ],
227
+ ['%"b%c3%a9b%c3%a9 ' ],
228
+ ['%b%c3%a9b%c3%a9" ' ],
229
+ ['%"b%C3%A9b%C3%A9" ' ],
222
230
];
223
231
}
224
232
}
Original file line number Diff line number Diff line change 15
15
16
16
/**
17
17
* @implements IteratorAggregate<string, Record>
18
- * @phpstan-import-type RecordData from Record
18
+ * @phpstan-type RecordData array{
19
+ * name: string,
20
+ * header_type: 'dictionary'|'list'|'item',
21
+ * raw: array<string>,
22
+ * canonical?: array<string>,
23
+ * must_fail?: bool,
24
+ * can_fail?: bool
25
+ * }
19
26
*/
20
27
final class RecordAggregate implements IteratorAggregate
21
28
{
You can’t perform that action at this time.
0 commit comments