PHP 8.6 Beta 3 Adds a Native clamp() Function and SortDirection Enum Ahead of November GA
PHP 8.6.0 Beta 3 landed with a native clamp() function, a SortDirection enum, and a trim() whitespace fix, as the release heads toward a November 19 GA.
Editor's Note ·
- Correction:
- The article states the clamp() RFC "argues a native implementation offers 'performance benefits'" while attributing this phrase to the RFC in quote marks. The word "benefit" does not appear anywhere on the cited RFC page (wiki.php.net/rfc/clamp_v2). The RFC's actual language is that a native function "would be even slightly faster than userland implementation using ternary, while providing some extra validation out of the box." The underlying claim is accurate; the quoted phrasing is a paraphrase, not the RFC's own words.
Overview
The PHP project released PHP 8.6.0 Beta 3 on September 10, 2026, the third beta of the upcoming 8.6 series and the last scheduled beta before the release candidate phase begins. The PHP.net homepage describes it as the “Third beta release of PHP 8.6.0” and notes the next milestone, RC1, is “planned for 24 September 2026.”
As with all pre-release builds, the PHP.net pre-release builds page warns that “the downloads on this page are not meant to be run in production. They are for testing only,” adding that the builds are “meant for the community to test whether no inadvertent changes have been made, and whether no regressions have been introduced.” PHP 8.6 is also set to be the first release distributed under the project’s new BSD 3-Clause license, as previously reported.
What We Know
Beta 3 arrives after the project’s soft feature freeze, meaning the RFCs targeting 8.6 are now locked in. Several of them add small but long-requested pieces to PHP’s standard library:
-
A native
clamp()function. Per the RFC, the newclamp(mixed $value, mixed $min, mixed $max): mixedfunction returns$valuewhen it falls within the given range, or the nearest bound otherwise — for example,clamp(6, min: 1, max: 3)returns3. The function throws aValueErrorif$minexceeds$maxor if either bound isNAN. The RFC passed 23 Yes to 3 No with 6 Abstain, and argues a native implementation offers “performance benefits” while following patterns already established in “C++, C#, Python, Java.” -
A
SortDirectionenum. The RFC addsenum SortDirection { case Ascending; case Descending; }, intended for use in APIs like$query->orderBy('created_at', SortDirection::Descending);. It passed 22 to 2 with 2 abstentions. The RFC argues that “PHP’s standard library has no type-safe way to express sort direction,” leaving developers to choose among integer constants such asSORT_ASC/SORT_DESC, string values, or boolean flags, and notes that “every major PHP framework and library ends up defining its own sort direction type.” -
Form feed added to
trim()’s default whitespace. The RFC adds the form-feed character\f(ASCII 12) to the default character mask stripped bytrim(),ltrim(),rtrim(), andchop(), alongside the existing space, tab, newline, carriage return, NUL-byte, and vertical tab. Before the change,trim("\fHello World\f")returned the string with the form feeds intact; after it, they’re stripped like other whitespace. The RFC passed unanimously, 25 Yes to 0 No, arguing that “Most modern programming languages treat\fas whitespace in their trimming functions” and that it brings PHP in line with Python, JavaScript, Rust, and Go. -
A grapheme-aware string reversal function. The RFC adds
grapheme_strrev(string $string): string, which reverses a string at the grapheme-cluster level rather than byte-by-byte the waystrrev()does, so multi-codepoint sequences like emoji with modifiers or right-to-left scripts aren’t corrupted. The RFC passed unanimously, 20 Yes to 0 No.
Release Timeline
According to the PHP 8.6 schedule maintained on the PHP wiki, the release moves through a hard feature freeze on September 22, 2026 — after which “features, whether requiring an RFC or not, must be merged only with approval from the RMs” — followed by RC1 on September 24, then RC2 through RC4 on a two-week cadence, with general availability targeted for November 19, 2026.
What We Don’t Know
PHP 8.6 remains in beta, and RFC voting for the release concluded at the soft feature freeze in August, so no further language-level additions are expected before GA. Whether any of the four features described here changes in edge-case behavior before the final release is not yet established; beta and release-candidate builds can still receive bug fixes before November’s stable release.