The pipe operator, |>, lets you pass a value through a chain of functions from left to right. This RFC from Larry Garfield adds it to PHP. The value on the left becomes the only argument to the callable on the right, so you can read the steps in the order they happen without a stack of temporary variables.

Before and after

These two snippets do the same thing:

$result = "Hello World"
    |> htmlentities(...)
    |> str_split(...)
    |> (fn($x) => array_map(strtoupper(...), $x))
    |> (fn($x) => array_filter($x, fn($v) => $v != 'O'));
$temp = "Hello World";
$temp = htmlentities($temp);
$temp = str_split($temp);
$temp = array_map(strtoupper(...), $temp);
$temp = array_filter($temp, fn($v) => $v != 'O');
$result = $temp;

The right side can be any callable that takes one argument, like strlen(...). A function that requires more than one argument fails, the same as calling it with too few. If the right side isn't a callable at all, PHP throws an Error. A pipe chain is an expression, so you can use it in places like match() arms and short property hooks.

Details

  • Precedence. Pipes run left to right, after arithmetic but before comparisons and ??. That means 'beep' |> strlen(...) == 4 compares the result.
  • Performance. PHP rewrites the pipe into plain function calls at compile time, so |> itself costs almost nothing. Any arrow functions you add still have their own small cost.
  • No references. Functions that take a parameter by reference aren't allowed on the right side.
  • Arrow functions need parentheses. A note added on August 28, 2025, says this, because without them an arrow function would swallow the rest of the chain.

The RFC points to libraries that emulate pipes today, like League Pipeline and Crell/fp, and says a native operator is faster. It sees a function composition operator and partial function application as the next steps.

What it means for existing code

Nothing breaks, since |> is new syntax.

The vote

It passed 33 to 7 on a Yes/No vote that needed a two-thirds majority. Votes were cast in May 2025, and it shipped in PHP 8.5.