Pipe Operator

The pipe operator is |>. It chains calls from methods from left to right, using the result of the first method as the only argument of the next method.

The pipe operator is compatible with every form of PHP callable: string, arrays, first class callable, closures, arrow functions with parenthesis, etc.

Pipe operator is not compatible with references.

The pipe operator should not be mistaken with the | pipe logical operator, which combines two values with a or logic.

<?php

    $result = abc |> trim(...) |> 'strtoupper'; // 'ABC'

?>

See also PHP 8.5: Pipe operator (|>), Introducing Piper: array and string manipulation with the pipe operator and My thoughts on Spatie/Piper.

Related : Logical Operators

Added in PHP 8.5