haphpiness

These are things in PHP which make me genuinely_happy();

Pipe Operator |>

PHP 8.5's most anticipated feature: the pipe operator. It takes the value on the left and passes it as the first argument to the callable on the right. No more nested function calls or temporary variables — just clean, left-to-right data flow.

// Before: nested calls — read inside-out
$result = strtolower(str_replace(' ', '-', str_replace('.', '', trim($title))));

// Before: temporary variables — cluttered
$result = trim($title);
$result = str_replace('.', '', $result);
$result = str_replace(' ', '-', $result);
$result = strtolower($result);

// After: pipe — read left to right, like a unix pipeline
$slug = $title
    |> trim(...)
    |> (fn($s) => str_replace('.', '', $s))
    |> (fn($s) => str_replace(' ', '-', $s))
    |> strtolower(...);

// Perfect for data transformation pipelines
$report = $rawData
    |> array_filter(fn($row) => $row['active'])
    |> array_map(fn($row) => $row['revenue'], ...)
    |> array_sum(...)
    |> (fn($total) => number_format($total, 2));

The pipe operator uses first-class callable syntax (...) for built-in functions and arrow functions or closures when you need to customize argument positions. It's the functional programming primitive that PHP's been missing.

Significance: Readability

Deeply nested function calls are one of the hardest things to read in any language. The pipe operator inverts the reading order to match the execution order: data flows left to right, top to bottom. It's how humans naturally think about transformations, and it makes complex data pipelines as readable as a bullet list.