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 4848
4949 - name : Run static analysis
5050 run : composer phpstan
51- if : ${{ matrix.php == '8.2 ' && matrix.stability == 'prefer-stable'}}
51+ if : ${{ matrix.php == '8.3 ' && matrix.stability == 'prefer-stable'}}
5252
5353 - name : Run Coding style rules
5454 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
4646 return new self ($ value );
4747 }
4848
49- if (1 === preg_match ('/%(?![0-9a-fA-F ]{2})/ ' , $ value )) {
49+ if (1 === preg_match ('/%(?![0-9a-f ]{2})/ ' , $ value )) {
5050 throw new SyntaxError ('The string ' .$ value .' contains invalid utf-8 encoded sequence. ' );
5151 }
5252
5353 $ value = (string ) preg_replace_callback (
54- ',%[A-Fa -f0-9]{2}, ' ,
54+ ',%[a -f0-9]{2}, ' ,
5555 fn (array $ matches ): string => rawurldecode ($ matches [0 ]),
5656 $ value
5757 );
Original file line number Diff line number Diff line change @@ -447,12 +447,11 @@ private static function extractDisplayString(string $httpValue): array
447447
448448 $ octet = substr ($ remainder , 0 , 2 );
449449 $ 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 )) {
453451 throw new SyntaxError ("The HTTP textual representation ' $ httpValue' for a DisplayString contains uppercased percent encoding sequence. " );
454452 }
455453
454+ $ remainder = substr ($ remainder , 2 );
456455 $ output .= $ char .$ octet ;
457456 }
458457
Original file line number Diff line number Diff line change @@ -24,8 +24,6 @@ final class ItemTest extends StructuredFieldTestCase
2424 'number-generated.json ' ,
2525 'string.json ' ,
2626 'string-generated.json ' ,
27- 'token.json ' ,
28- 'token-generated.json ' ,
2927 'item.json ' ,
3028 'date.json ' ,
3129 ];
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
143143
144144 #[Test]
145145 #[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
147147 {
148148 $ field = $ this ->parser ->parseValue ($ httpValue );
149149 if (is_scalar ($ expected )) {
@@ -197,6 +197,11 @@ public static function provideHttpValueForDataType(): iterable
197197 'httpValue ' => '?0 ' ,
198198 'expected ' => false ,
199199 ];
200+
201+ yield 'it parses a display string ' => [
202+ 'httpValue ' => '%"b%c3%a9b%c3%a9" ' ,
203+ 'expected ' => DisplayString::fromDecoded ('bébé ' ),
204+ ];
200205 }
201206
202207 #[Test]
@@ -219,6 +224,9 @@ public static function provideInvalidHttpValueForDataType(): array
219224 ['@1_000_000_000_000.0 ' ],
220225 ['-1_000_000_000_000.0 ' ],
221226 [' ' ],
227+ ['%"b%c3%a9b%c3%a9 ' ],
228+ ['%b%c3%a9b%c3%a9" ' ],
229+ ['%"b%C3%A9b%C3%A9" ' ],
222230 ];
223231 }
224232}
Original file line number Diff line number Diff line change 1515
1616/**
1717 * @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+ * }
1926 */
2027final class RecordAggregate implements IteratorAggregate
2128{
You can’t perform that action at this time.
0 commit comments