2727use Typhoon \PHPStanTypeParser \Context ;
2828use Typhoon \PHPStanTypeParser \CustomParser ;
2929use Typhoon \Type ;
30- use Typhoon \Type \ArrayDefaultT ;
30+ use Typhoon \Type \ArrayBareT ;
3131use Typhoon \Type \ArrayT ;
3232use Typhoon \Type \CallableT ;
3333use Typhoon \Type \ConstantT ;
34- use Typhoon \Type \IterableDefaultT ;
34+ use Typhoon \Type \IterableBareT ;
3535use Typhoon \Type \IterableT ;
3636use Typhoon \Type \ListT ;
3737use Typhoon \Type \Parameter ;
@@ -232,8 +232,8 @@ private function int(array $genericNodes): Type
232232 return match (\count ($ genericNodes )) {
233233 0 => intT,
234234 2 => intRangeT (
235- min: self ::intRangeLimit ($ genericNodes [0 ], ' min ' ),
236- max: self ::intRangeLimit ($ genericNodes [1 ], ' max ' ),
235+ min: self ::intRangeLimit ($ genericNodes [0 ]),
236+ max: self ::intRangeLimit ($ genericNodes [1 ]),
237237 ),
238238 default => throw new \LogicException (\sprintf (
239239 'Int range type should have 2 type arguments, got %d ' ,
@@ -242,22 +242,16 @@ private function int(array $genericNodes): Type
242242 };
243243 }
244244
245- /**
246- * @param 'min'|'max' $name
247- */
248- private function intRangeLimit (TypeNode $ type , string $ name ): ?int
245+ private function intRangeLimit (TypeNode $ type ): int
249246 {
250247 $ string = (string ) $ type ;
251248
252- if ($ string === $ name ) {
253- return null ;
254- }
255-
256- if (is_numeric ($ string ) && !str_contains ($ string , '. ' )) {
257- return (int ) $ string ;
258- }
259-
260- throw new \LogicException ();
249+ return match (true ) {
250+ $ string === 'min ' => PHP_INT_MIN ,
251+ $ string === 'max ' => PHP_INT_MAX ,
252+ preg_match ('/^-?\d+$/D ' , $ string ) === 1 => (int ) $ string ,
253+ default => throw new \LogicException (),
254+ };
261255 }
262256
263257 /**
@@ -312,7 +306,7 @@ private function list(array $templateArguments, bool $isNonEmpty = false): ListT
312306 /**
313307 * @param list<Type> $templateArguments
314308 */
315- private function array (array $ templateArguments , bool $ isNonEmpty = false ): ArrayDefaultT |ArrayT
309+ private function array (array $ templateArguments , bool $ isNonEmpty = false ): ArrayBareT |ArrayT
316310 {
317311 return match ($ number = \count ($ templateArguments )) {
318312 0 => $ isNonEmpty ? new ArrayT (isNonEmpty: true ) : arrayT,
@@ -325,7 +319,7 @@ private function array(array $templateArguments, bool $isNonEmpty = false): Arra
325319 /**
326320 * @param list<Type> $templateArguments
327321 */
328- private function iterable (array $ templateArguments ): IterableDefaultT |IterableT
322+ private function iterable (array $ templateArguments ): IterableBareT |IterableT
329323 {
330324 return match ($ number = \count ($ templateArguments )) {
331325 0 => iterableT,
0 commit comments