-
-
Notifications
You must be signed in to change notification settings - Fork 152
[8.6] Add clamp function
#554
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: 1.x
Are you sure you want to change the base?
Conversation
|
That would be for PHP 8.6, isn't it? |
Correct, moving it. |
5bbf49c to
d88b259
Compare
bead94d to
c9033e5
Compare
248a2dc to
236eb98
Compare
236eb98 to
daaa8bb
Compare
|
php/php-src#19434 is merged (will land in PHP 8.6) |
| * @template V | ||
| * @template L | ||
| * @template H | ||
| * | ||
| * @param V $value | ||
| * @param L $min | ||
| * @param H $max | ||
| * | ||
| * @return V|L|H | ||
| */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the logic behind L and H? Maybe this could be more explanatory with TVal, TMin, TMax.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
L = Low, H = High.
It was because min and max both start with an M.
But I'm fine using full words such as Value, Minimum, Maximum.
| if (\is_float($min) && \is_nan($min)) { | ||
| self::throwValueErrorIfAvailable('clamp(): Argument #2 ($min) cannot be NAN'); | ||
| } | ||
|
|
||
| if (\is_float($max) && is_nan($max)) { | ||
| self::throwValueErrorIfAvailable('clamp(): Argument #3 ($max) cannot be NAN'); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It was merged using must in the wording, it should be updated here as well. See https://github.com/php/php-src/blob/f80338cb926a6dbe8007ad62776bdb4f8d6dd047/ext/standard/math.c#L393-L403
Co-authored-by: Alexandre Daubois <2144837+alexandre-daubois@users.noreply.github.com>
RFC: https://wiki.php.net/rfc/clamp_v2
Original implementation: php/php-src#19434
Documentation: php/doc-en#4814