PHP 8.5 adds built-in URI extension, pipe operator, updated clone syntax, and much more
PHP 8.5 has been released as the latest version of this widely used scripting language, bringing significant updates aimed at web developers. Among the most prominent additions, a built-in URI extension allows developers to parse, normalize, and handle URLs according to RFC 3986 and WHATWG URL standards. The new pipeline operator | enables left-to-right chaining of callables, making data flow through functions simpler without relying on intermediate variables.
Following these core changes, the release introduces an updated clone() syntax, offering a streamlined way to clone objects and set properties for immutable, or readonly, classes in one step. API safety receives attention with the #[\NoDiscard] attribute, which generates warnings if a return value goes unused. In addition, static closures and first-class callables can now appear in constant expressions, such as attribute parameters, providing developers more flexibility.
Efficiency improvements include the ability for handles to persist across multiple PHP requests, reducing the overhead of connection initializations. Developers also gain new utility with the array_first() and array_last() functions, which reliably extract the first or last value or null from arrays. PHP 8.5 also brings further feature additions, deprecations, and some backward compatibility breaks.
