Menu

Post image 1
Post image 2
1 / 2
0

PHP 8.5's pipe operator and the array stdlib problem

DEV Community·delacry·about 1 month ago
#bWIGvuL4
#gotcha#php#laravel#fullscreen#array_map#pipe
Reading 0:00
15s threshold

PHP 8.5 shipped a pipe operator, from Larry Garfield's RFC (approved 33-7). The marketing examples look great: $slug = $title |> trim ( ... ) |> strtolower ( ... ); Enter fullscreen mode Exit fullscreen mode Reads top to bottom, no nesting, types flow. For chains of single-input transformations, which is what the RFC was explicit about targeting, the operator does exactly what you'd want. The friction starts when you reach for it on PHP's array stdlib, which is where most day-to-day chaining happens. Most of what follows isn't really a flaw in the pipe operator itself. It's the stdlib's call-shape inconsistencies leaking through whatever composition mechanism you put on top of them. The naive port A common form-handling task: clean user-submitted tags and sort a-z.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.

Read More