What's New in PHP 8.6 php.net · 276 points · 126 comments · HN thread TL;DR PHP ...

@best30

What's New in PHP 8.6 php.net · 276 points · 126 comments · HN thread

TL;DR PHP 8.6.0 has been released with headline features including partial function application, a new Duration class, an Io\Poll API for scalable stream multiplexing, a clamp() function, a SortDirection enum, and readonly property defaults. The release notes also list many deprecations and smaller changes. The thread is dominated by a concurrent security advisory set for the same day and by a broader debate over PHP's language design.

  • Partial Function Application lets callers fix some arguments with ? and ... placeholders, returning a Closure that is called once the remaining arguments are supplied.
  • The new \Time\Duration class represents elapsed time independent of timezone, spanning more than 250 years at nanosecond precision.
  • The Io\Poll API uses epoll, kqueue, event ports or WSAPoll to monitor many streams without stream_select()'s limits, intended as a base for ReactPHP and AMPHP.
  • clamp($value, $min, $max) is added as a built-in, works with any comparable value including Duration, and returns the nearest boundary when out of range.
  • Stream errors can now throw StreamException with structured StreamError objects, and readonly properties and readonly classes can declare default values.
  • Many deprecations are included, such as return inside finally, mb_ereg(), spl_object_hash(), strcoll(), and is_double()/is_long().

Discussion The thread is a mix of practical upgrade talk, design debate, and a lot of commentary on PHP's reputation. Much of the early discussion concerns a set of security advisories published the same day, with commenters sorting out which versions (8.5+ versus older Debian-packaged 8.3 and 8.4) are affected and whether 8.6.0 includes the fixes. The feature discussion is more mixed: some welcome partial application, clamp(), and the stream error handling, while others question the purpose of the ? placeholder syntax, the value of the Duration class, and PHP's growing surface area. The mood is skeptical but not hostile, with several commenters defending modern PHP against the familiar 'PHP bad' criticism.

  • Upgrade promptly because of the security fixes (many): Several commenters point out the CVE advisories and critical fixes, advising users to patch soon. Others reply that this is simply the regular four-week release cycle and that the security content is what makes it urgent.
  • Modern PHP is good and the criticism is shallow (some): Commenters with long PHP experience argue that PHP 8+ is pleasant and that repeated 'PHP bad' comments add little. They note that many old complaints no longer apply.
  • Language surface keeps growing and adds complexity (some): Several argue that each release adds features, making the language harder to learn, maintain and secure, and that the JIT and property hooks show the cost. Others counter that many features are useful but not essential.
  • Partial function syntax is confusing or unnecessary (some): Critics say the ? placeholder makes calls look like declarations and that a short arrow function is clearer. Supporters find it elegant and useful for pipelines and callbacks.
  • Backward compatibility and gradual breaking changes are a problem (a few): One commenter cites old PHP 5 code that broke when methods began throwing errors, and argues that frequent breaking changes push sites onto unsupported versions. A reply says PHP usually deprecates gradually.
  • Unicode and string handling remain weak (a few): A critic says the lack of native Unicode strings is a serious weakness. Others say UTF-8 in byte strings with mb_* functions works fine and that UTF-16 would have been a mistake.

Links from the comments

#php #release #security #languageDesign #partialFunctions #streams