@@ -12,11 +12,11 @@ function doMatch(string $s): void {
1212 assertType ('array{}|array{string} ' , $ matches );
1313
1414 if (preg_match ('/Price: (£|€)\d+/ ' , $ s , $ matches )) {
15- assertType (' array{string, non-empty-string} ' , $ matches );
15+ assertType (" array{string, '£'|'€'} " , $ matches );
1616 } else {
1717 assertType ('array{} ' , $ matches );
1818 }
19- assertType (' array{}|array{string, non-empty-string} ' , $ matches );
19+ assertType (" array{}|array{string, '£'|'€'} " , $ matches );
2020
2121 if (preg_match ('/Price: (£|€)(\d+)/i ' , $ s , $ matches )) {
2222 assertType ('array{string, non-empty-string, numeric-string} ' , $ matches );
@@ -54,9 +54,9 @@ function doMatch(string $s): void {
5454 assertType ("array{}|array{0: string, 1: 'a', 2: string, 3: 'c', name?: non-empty-string, 4?: non-empty-string} " , $ matches );
5555
5656 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 );
5858 }
59- assertType (' array{}|array{0: string, 1?: non-empty-string} ' , $ matches );
59+ assertType (" array{}|array{0: string, 1?: 'a'|'b'} " , $ matches );
6060
6161 if (preg_match ('/(foo)(bar)(baz)+/ ' , $ s , $ matches )) {
6262 assertType ("array{string, 'foo', 'bar', non-falsy-string} " , $ matches );
@@ -356,30 +356,30 @@ function bug11291(string $s): void {
356356function bug11323a (string $ s ): void
357357{
358358 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 );
360360 } else {
361361 assertType ('array{} ' , $ matches );
362362 }
363- assertType (' array{}|array{0: string, currency: non-empty-string , 1: non-empty-string} ' , $ matches );
363+ assertType (" array{}|array{0: string, currency: '£'|'€' , 1: '£'|'€'} " , $ matches );
364364}
365365
366366function bug11323b (string $ s ): void
367367{
368368 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 );
370370 } else {
371371 assertType ('array{} ' , $ matches );
372372 }
373- assertType (' array{}|array{0: string, currency: non-empty-string , 1: non-empty-string} ' , $ matches );
373+ assertType (" array{}|array{0: string, currency: '£'|'€' , 1: '£'|'€'} " , $ matches );
374374}
375375
376376function unmatchedAsNullWithMandatoryGroup (string $ s ): void {
377377 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 );
379379 } else {
380380 assertType ('array{} ' , $ matches );
381381 }
382- assertType (' array{}|array{0: string, currency: non-empty-string , 1: non-empty-string} ' , $ matches );
382+ assertType (" array{}|array{0: string, currency: '£'|'€' , 1: '£'|'€'} " , $ matches );
383383}
384384
385385function (string $ s ): void {
@@ -608,17 +608,29 @@ function (string $s): void {
608608};
609609
610610function (string $ s ): void {
611- if (preg_match ('/Price: (a|0 )/ ' , $ s , $ matches )) {
611+ if (preg_match ('/Price: (a|bc? )/ ' , $ s , $ matches )) {
612612 assertType ("array{string, non-empty-string} " , $ matches );
613613 }
614614};
615615
616616function (string $ s ): void {
617- if (preg_match ('/Price: (aa|0 )/ ' , $ s , $ matches )) {
617+ if (preg_match ('/Price: (a|\d )/ ' , $ s , $ matches )) {
618618 assertType ("array{string, non-empty-string} " , $ matches );
619619 }
620620};
621621
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+
622634function (string $ s ): void {
623635 if (preg_match ('/( \d+ )/x ' , $ s , $ matches )) {
624636 assertType ('array{string, numeric-string} ' , $ matches );
0 commit comments