@@ -12,11 +12,11 @@ function doMatch(string $s): void {
12
12
assertType ('array{}|array{string} ' , $ matches );
13
13
14
14
if (preg_match ('/Price: (£|€)\d+/ ' , $ s , $ matches )) {
15
- assertType (' array{string, non-empty-string} ' , $ matches );
15
+ assertType (" array{string, '£'|'€'} " , $ matches );
16
16
} else {
17
17
assertType ('array{} ' , $ matches );
18
18
}
19
- assertType (' array{}|array{string, non-empty-string} ' , $ matches );
19
+ assertType (" array{}|array{string, '£'|'€'} " , $ matches );
20
20
21
21
if (preg_match ('/Price: (£|€)(\d+)/i ' , $ s , $ matches )) {
22
22
assertType ('array{string, non-empty-string, numeric-string} ' , $ matches );
@@ -54,9 +54,9 @@ function doMatch(string $s): void {
54
54
assertType ("array{}|array{0: string, 1: 'a', 2: string, 3: 'c', name?: non-empty-string, 4?: non-empty-string} " , $ matches );
55
55
56
56
if (preg_match ('/(a|b)|(?:c)/ ' , $ s , $ matches )) {
57
- assertType (' array{0: string, 1?: non-empty-string} ' , $ matches );
57
+ assertType (" array{0: string, 1?: 'a'|'b'} " , $ matches );
58
58
}
59
- assertType (' array{}|array{0: string, 1?: non-empty-string} ' , $ matches );
59
+ assertType (" array{}|array{0: string, 1?: 'a'|'b'} " , $ matches );
60
60
61
61
if (preg_match ('/(foo)(bar)(baz)+/ ' , $ s , $ matches )) {
62
62
assertType ("array{string, 'foo', 'bar', non-falsy-string} " , $ matches );
@@ -356,30 +356,30 @@ function bug11291(string $s): void {
356
356
function bug11323a (string $ s ): void
357
357
{
358
358
if (preg_match ('/Price: (?P<currency>£|€)\d+/ ' , $ s , $ matches )) {
359
- assertType (' array{0: string, currency: non-empty-string , 1: non-empty-string} ' , $ matches );
359
+ assertType (" array{0: string, currency: '£'|'€' , 1: '£'|'€'} " , $ matches );
360
360
} else {
361
361
assertType ('array{} ' , $ matches );
362
362
}
363
- assertType (' array{}|array{0: string, currency: non-empty-string , 1: non-empty-string} ' , $ matches );
363
+ assertType (" array{}|array{0: string, currency: '£'|'€' , 1: '£'|'€'} " , $ matches );
364
364
}
365
365
366
366
function bug11323b (string $ s ): void
367
367
{
368
368
if (preg_match ('/Price: (?<currency>£|€)\d+/ ' , $ s , $ matches )) {
369
- assertType (' array{0: string, currency: non-empty-string , 1: non-empty-string} ' , $ matches );
369
+ assertType (" array{0: string, currency: '£'|'€' , 1: '£'|'€'} " , $ matches );
370
370
} else {
371
371
assertType ('array{} ' , $ matches );
372
372
}
373
- assertType (' array{}|array{0: string, currency: non-empty-string , 1: non-empty-string} ' , $ matches );
373
+ assertType (" array{}|array{0: string, currency: '£'|'€' , 1: '£'|'€'} " , $ matches );
374
374
}
375
375
376
376
function unmatchedAsNullWithMandatoryGroup (string $ s ): void {
377
377
if (preg_match ('/Price: (?<currency>£|€)\d+/ ' , $ s , $ matches , PREG_UNMATCHED_AS_NULL )) {
378
- assertType (' array{0: string, currency: non-empty-string , 1: non-empty-string} ' , $ matches );
378
+ assertType (" array{0: string, currency: '£'|'€' , 1: '£'|'€'} " , $ matches );
379
379
} else {
380
380
assertType ('array{} ' , $ matches );
381
381
}
382
- assertType (' array{}|array{0: string, currency: non-empty-string , 1: non-empty-string} ' , $ matches );
382
+ assertType (" array{}|array{0: string, currency: '£'|'€' , 1: '£'|'€'} " , $ matches );
383
383
}
384
384
385
385
function (string $ s ): void {
@@ -608,17 +608,29 @@ function (string $s): void {
608
608
};
609
609
610
610
function (string $ s ): void {
611
- if (preg_match ('/Price: (a|0 )/ ' , $ s , $ matches )) {
611
+ if (preg_match ('/Price: (a|bc? )/ ' , $ s , $ matches )) {
612
612
assertType ("array{string, non-empty-string} " , $ matches );
613
613
}
614
614
};
615
615
616
616
function (string $ s ): void {
617
- if (preg_match ('/Price: (aa|0 )/ ' , $ s , $ matches )) {
617
+ if (preg_match ('/Price: (a|\d )/ ' , $ s , $ matches )) {
618
618
assertType ("array{string, non-empty-string} " , $ matches );
619
619
}
620
620
};
621
621
622
+ function (string $ s ): void {
623
+ if (preg_match ('/Price: (a|0)/ ' , $ s , $ matches )) {
624
+ assertType ("array{string, '0'|'a'} " , $ matches );
625
+ }
626
+ };
627
+
628
+ function (string $ s ): void {
629
+ if (preg_match ('/Price: (aa|0)/ ' , $ s , $ matches )) {
630
+ assertType ("array{string, '0'|'aa'} " , $ matches );
631
+ }
632
+ };
633
+
622
634
function (string $ s ): void {
623
635
if (preg_match ('/( \d+ )/x ' , $ s , $ matches )) {
624
636
assertType ('array{string, numeric-string} ' , $ matches );
0 commit comments