@@ -112,13 +112,13 @@ function (string $size): void {
112112
113113function (string $ size ): void {
114114 if (preg_match_all ('/ab(?P<num>\d+)(?P<suffix>ab)?/ ' , $ size , $ matches , PREG_SET_ORDER |PREG_OFFSET_CAPTURE )) {
115- assertType ("list<array{0: array{string, int<0 , max>}, num: array{numeric-string, int<0 , max>}, 1: array{numeric-string, int<0 , max>}, suffix?: array{'ab', int<0 , max>}, 2?: array{'ab', int<0 , max>}}> " , $ matches );
115+ assertType ("list<array{0: array{string, int<-1 , max>}, num: array{numeric-string, int<-1 , max>}, 1: array{numeric-string, int<-1 , max>}, suffix?: array{'ab', int<-1 , max>}, 2?: array{'ab', int<-1 , max>}}> " , $ matches );
116116 }
117117};
118118
119119function (string $ size ): void {
120120 if (preg_match_all ('/ab(?P<num>\d+)(?P<suffix>ab)?/ ' , $ size , $ matches , PREG_PATTERN_ORDER |PREG_OFFSET_CAPTURE )) {
121- assertType ("array{0: list<array{string, int<0 , max>}>, num: list<array{numeric-string, int<0 , max>}>, 1: list<array{numeric-string, int<0 , max>}>, suffix: list<''|array{ 'ab', int<0 , max>}>, 2: list<''|array{ 'ab', int<0 , max>}>} " , $ matches );
121+ assertType ("array{0: list<array{string, int<-1 , max>}>, num: list<array{numeric-string, int<-1 , max>}>, 1: list<array{numeric-string, int<-1 , max>}>, suffix: list<array{ ''|'ab', int<-1 , max>}>, 2: list<array{ ''|'ab', int<-1 , max>}>} " , $ matches );
122122 }
123123};
124124
@@ -142,7 +142,7 @@ public function sayHello(string $content): void
142142 return ;
143143 }
144144
145- assertType ('array{list<array{string, int<0 , max>}>} ' , $ matches );
145+ assertType ('array{list<array{string, int<-1 , max>}>} ' , $ matches );
146146 }
147147
148148 public function sayFoo (string $ content ): void
@@ -162,4 +162,16 @@ public function sayBar(string $content): void
162162
163163 assertType ('array{list<string>} ' , $ matches );
164164 }
165+
166+ function doFoobar (string $ s ): void {
167+ if (preg_match_all ('/(foo)?(bar)?(baz)?/ ' , $ s , $ matches , PREG_OFFSET_CAPTURE )) {
168+ assertType ("array{list<array{string, int<-1, max>}>, list<array{''|'foo', int<-1, max>}>, list<array{''|'bar', int<-1, max>}>, list<array{''|'baz', int<-1, max>}>} " , $ matches );
169+ }
170+ }
171+
172+ function doFoobarNull (string $ s ): void {
173+ if (preg_match_all ('/(foo)?(bar)?(baz)?/ ' , $ s , $ matches , PREG_OFFSET_CAPTURE |PREG_UNMATCHED_AS_NULL )) {
174+ assertType ("array{list<array{string|null, int<-1, max>}>, list<array{'foo'|null, int<-1, max>}>, list<array{'bar'|null, int<-1, max>}>, list<array{'baz'|null, int<-1, max>}>} " , $ matches );
175+ }
176+ }
165177}
0 commit comments