@@ -93,9 +93,10 @@ function doNonCapturingGroup(string $s): void {
93
93
94
94
function doNamedSubpattern (string $ s ): void {
95
95
if (preg_match ('/\w-(?P<num>\d+)-(\w)/ ' , $ s , $ matches )) {
96
- assertType ('array{0: string, num: string, 1: string, 2: string} ' , $ matches );
96
+ // could be assertType('array{0: string, num: string, 1: string, 2: string, 3: string}', $matches);
97
+ assertType ('array<string> ' , $ matches );
97
98
}
98
- assertType ('array{}|array{0: string, num: string, 1: string, 2: string} ' , $ matches );
99
+ assertType ('array< string> ' , $ matches );
99
100
100
101
if (preg_match ('/^(?<name>\S+::\S+)/ ' , $ s , $ matches )) {
101
102
assertType ('array{0: string, name: string, 1: string} ' , $ matches );
@@ -364,22 +365,12 @@ function bug11291(string $s): void {
364
365
assertType ('array{}|array{0: string, 1: string, 2?: string, 3?: string} ' , $ matches );
365
366
}
366
367
367
- function bug11323a (string $ s ): void
368
- {
369
- if (preg_match ('/Price: (?P<currency>£|€)\d+/ ' , $ s , $ matches )) {
368
+ function unmatchedAsNullWithMandatoryGroup (string $ s ): void {
369
+ if (preg_match ('/Price: (?<currency>£|€)\d+/ ' , $ s , $ matches , PREG_UNMATCHED_AS_NULL )) {
370
370
assertType ('array{0: string, currency: string, 1: string} ' , $ matches );
371
371
} else {
372
372
assertType ('array{} ' , $ matches );
373
373
}
374
374
assertType ('array{}|array{0: string, currency: string, 1: string} ' , $ matches );
375
375
}
376
376
377
- function bug11323b (string $ s ): void
378
- {
379
- if (preg_match ('/Price: (?<currency>£|€)\d+/ ' , $ s , $ matches )) {
380
- assertType ('array{0: string, currency: string, 1: string} ' , $ matches );
381
- } else {
382
- assertType ('array{} ' , $ matches );
383
- }
384
- assertType ('array{}|array{0: string, currency: string, 1: string} ' , $ matches );
385
- }
0 commit comments