flow icon indicating copy to clipboard operation
flow copied to clipboard

[Proposal]: IntegerRangeType

Open norberttech opened this issue 6 months ago • 1 comments

Describe the Proposal

PHPStan allows to define integer types as int<min,max>, would be nice to be able to do the same on the code level since currently there is no way to narrow the types when int<1, max> is required somewhere

API Adjustments

type_integer_range(1, PHP_INT_MAX) - integer<1, max>

Are you intenting to also work on proposed change?

None

Are you interested in sponsoring this change?

None

Integration & Dependencies

No response

norberttech avatar Jun 21 '25 14:06 norberttech

Unfortunately it seems that PHPStan does not understand int<TMin, TMax> https://phpstan.org/r/5097e96a-5d7d-43f6-b882-5178d8abed49 so this needs to go on hold for now :(

Reference: https://github.com/phpstan/phpstan/issues/13174

norberttech avatar Jun 21 '25 15:06 norberttech