Skip to content

Use native clamp function inside util#337

Closed
jnoordsij wants to merge 1 commit intonette:masterfrom
jnoordsij:native-clamp
Closed

Use native clamp function inside util#337
jnoordsij wants to merge 1 commit intonette:masterfrom
jnoordsij:native-clamp

Conversation

@jnoordsij
Copy link
Copy Markdown

  • new feature
  • no (potentially?)
  • doc PR: n/a

This replaces the manual clamp implementation with the PHP native clamp, which is new in PHP 8.6 (unreleased). See also:

Note that the only behavioral change is the type of exception and corresponding message. Migrating towards the new PHP native one seems like a reasonable choice to me, but if preferable I'm fine with catching it and manually throwing the old one.

@dg
Copy link
Copy Markdown
Member

dg commented Apr 27, 2026

There must be a version check using PHP_VERSION_ID.

@jnoordsij
Copy link
Copy Markdown
Author

That's why I've also added the (Symfony) polyfill; it is setup to provide the function if not natively available. I must admit the PR description was slightly short and did not clarify this entirely, but as such it should work fine both on current and future PHP versions.

@dg
Copy link
Copy Markdown
Member

dg commented Apr 27, 2026

🤦‍♂️

@dg dg closed this Apr 27, 2026
@jnoordsij jnoordsij deleted the native-clamp branch April 27, 2026 14:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants