On Thursday 28 August 2025 13:28:43 (+02:00), Tim Düsterhus wrote:

> Hi
> 
> >> There's precedent in ext/random with the Randomizer::getFloat() method 
> >> that takes a Random\IntervalBoundary enum to decide on the the 
> >> interpretation of the boundary values. Translated to `clamp()` this could 
> >> mean:
> >> > If it weren't living in the Random extension, that very Enum could have 
> >> > been used.
> 
> Indeed. Back when introducing the enum, we actually had a discussion about 
> naming and “placement”. In the end, we opted to make it ext/random-specific 
> as a more conservative choice. I think back then it was the first native enum.
> 
> See https://externals.io/message/118810#118910 and 
> https://chat.stackoverflow.com/transcript/11?m=55444127#55444127.
> 
> If a new general-purpose IntervalBoundary enum is introduced, I'm happy to 
> widen the type in ext/random from `\Random\IntervalBoundary` to 
> `\IntervalBoundary|\Random\IntervalBoundary` (and deprecate the latter in one 
> of the following versions).
> 
> Best regards
> Tim Düsterhus
> 

Not sure if I'm too much off track here: As we can't alias classes in userland 
that are internal classes, internally PHP could do the oppsite and given clamp 
could borrow it out to/from \Random\IntervalBoundary given we have enough 
discipline. That also could buy some time on the widening idea and preserve a 
bit of the conservative approach to further on defer the details until 
necessary.

Widening is certainly correct in its own right, but why not keep the door open 
this way so one day we can applaud the first internal enum for its foresight?

-- hakre

Reply via email to