News for hackers. Stuff that matters.
Re:PHP 8.5 Adds Pipe Operator: What it means by qwertox on Tuesday August 05, 2025 @03:38AM (#44795317)
It's true that pipes are more readable, and for many cases they will be the better option, but the example of nested functions just doesn't hold.

That's like saying someone would use this:

   $result = $arr |> fn($x) => array_column($x, 'tags') |> fn($x) => array_merge(...$x) |> array_unique(...) |> array_values(...)
which is harder to reason about than the nested functions.

   array_values( array_unique( array_merge( ...array_column($arr, 'tags') ) ) );
or

   array_values(
     array_unique(
       array_merge(
         ...array_column($arr, 'tags')
       )
     )
   );
Re:PHP 8.5 Adds Pipe Operator: What it means by navalino on Tuesday August 05, 2025 @04:15AM (#44795544)
It is more readable and better option — you have to parse it from the innermost function to the outermost just to understand what it's doing. With the pipe, it's more straightforward: you read it step by step — do this, then that, then the next — just like how you'd naturally read instructions.
Re:PHP 8.5 Adds Pipe Operator: What it means by account42 on Tuesday August 05, 2025 @06:27AM (#44796358)
The pipe syntax is much more readable than nested function calls when you need additional arguments for intermediate functions. With nested functions it becomes hard to see which functions those arguments belong to even if you try to help it with formatting.
Re:PHP 8.5 Adds Pipe Operator: What it means by troupo on Tuesday August 05, 2025 @09:16AM (#44797605)
Why didn't you format the pipes, too?

  $result = $arr
    |> fn($x) => array_column($x, 'tags')
    |> fn($x) => array_merge(...$x)
    |> array_unique(...)
    |> array_values(...)
vs

   array_values(
     array_unique(
       array_merge(
         ...array_column($arr, 'tags')
       )
     )
   );
With pipes you have linear sequence of data transformations. With nested function calls you have to start with innermost function and proceed all the way top the outermost layer.
Re:PHP 8.5 Adds Pipe Operator: What it means by qwertox on Wednesday August 06, 2025 @06:02PM (#44818381)
Because they were already formatted that way to begin with.