Status: The Pipe Operator is a new feature being introduced in PHP 8.5 (November 20, 2025).
The Pipe Operator |>
is a language feature that enables functional
composition by chaining operations in a left-to-right syntax.
Rather than nesting function calls or creating intermediate variables, the pipe operator passes the result of one expression directly as the first parameter to the next callable.
Traditional approach:
With pipe operator:
Let's compare code in the context of making donuts. Go ahead - add a few toppings!
Both these examples produce identical results, but the pipe syntax transforms how we read and follow the flow of the code.
The traditional approach shows how calls are nested and therefore forces you to parse the code from the inside out.
You must first find bakeDonut()
, then move outward for each topping.
The pipe operator follows a natural reading flow: start with the input, then follow each step sequentially. This eliminates the cognitive overhead of matching parentheses and makes it trivial to add, remove, or reorder the steps.
User processing pipeline:
$adminCount = getUsers() |> fn($users) => array_filter($users, isAdmin(...)) |> count(...);
This pipeline:
A |> B |> C
The pipe operator works well with PHP 8.1's
first-class callable syntax ...
:
// First-class callable syntax$result = "hello world" |> strtoupper(...) |> trim(...);
// Works with any callable type$data = getUsers() |> fn($users) => array_filter($users, isAdmin(...)) // Function reference |> array_values(...) // Built-in function |> Processor::processUsers(...) // Static method |> $processor->transform(...); // Instance method
The ...
syntax creates a callable reference without invoking the function, making it useful for pipe chains.
Work has begun on a complementary feature called
Partial Function Application targeting PHP 8.6.
This enhancement would introduce ?
as a placeholder to the syntax and provide better control over parameter
placement in multi-argument functions.
Current limitation with pipe operator:
// Requires a closure for multi-parameter functions$result = $data |> fn($x) => str_replace(' ', '-', $x);
Proposed syntax:
// Clean placeholder syntax with partial function application$result = $data |> str_replace(' ', '-', ?);
The ?
placeholder creates a partially applied function where the piped value fills the marked position.
This would remove the need to wrap steps in a closure for multi-parameter functions, making pipe chains more
readable and concise.
Also being considered:
While this feature is still being discussed, and not yet confirmed for any specific release, it does demonstrate the continued effort being made to improve PHP's programming capabilities.
Did you know this article uses Event Sourcing to store your donut creation? The events are used to create the preview and code examples! Interested in Event Sourcing? Be sure to subscribe to my newsletter!