With the upcoming release of PHP 8.5 (scheduled for November 20, 2025), a new pipe operator (|>
) makes it possible to chain first-class callables in a functional, left-to-right style. This design simplifies nested calls, improves readability, and retains performance similar to traditional nested code
Takes the output of the expression on the left side
Passes it as the first (and only) parameter to the callable on the right side
Example Usage
$result = "Hello World"
|> strtoupper(...)
|> str_shuffle(...)
|> trim(...);
This is functionally equivalent to:
$result = trim(str_shuffle(strtoupper("Hello World")));
Callables must accept exactly one required parameter
If a callable expects multiple parameters or none at all, the pipeline will either error or silently drop parameters php.net.
By-reference parameters usually not supported
Most functions expecting parameters by reference won't work in the pipe chain (some exceptions like extract()
and array_multisort()
exist) Reddit+3PHP.Watch+3SensioLabs+3.
Return type void
becomes null
Any callable with a void
return will result in null
for the rest of the chain.
+
, ??
, and the ternary operatoReal‑World Example
$fullName = 'Fred Flintstone';
$result = $fullName
|> fn($x) => explode(' ', $x) // ['Fred', 'Flintstone']
|> fn($x) => implode('_', $x) // 'Fred_Flintstone'
|> strtolower(...); // 'fred_flintstone'
echo $result;
Cleaner, expressive syntax — no nested parentheses or temporary assignments
Easier to read — supports point‑free and pipeline-style code
Efficient execution — similar performance to nested calls due to VM optimizations
@2025 Xunut All rights reserved