Re: [RFC] [Discussion] Add clamp function
| From: | Tim Düsterhus | Date: | Thu, 28 Aug 2025 11:28:43 +0000 |
| Subject: | Re: [RFC] [Discussion] Add clamp function | ||
| References: | 1 2 3 4 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-128582@lists.php.net to get a copy of this message | ||
Hi
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 fromThere'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 toIf it weren't living in the Random extension, that very Enum could have been used.clamp()this could mean:
\Random\IntervalBoundary to \IntervalBoundary|\Random\IntervalBoundary (and deprecate the latter in one of the following versions).
Best regards
Tim Düsterhus