haphpiness

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

new Without Parentheses

PHP 8.4 allows chaining methods and accessing properties on a newly created object without wrapping new in parentheses. A small syntax fix that removes a long-standing annoyance.

// Before PHP 8.4: parentheses required for chaining
$name = (new ReflectionClass($obj))->getName();
$date = (new DateTime('now'))->format('Y-m-d');
$items = (new Collection([1, 2, 3]))->map(fn($n) => $n * 2)->toArray();

// After PHP 8.4: just chain directly
$name = new ReflectionClass($obj)->getName();
$date = new DateTime('now')->format('Y-m-d');
$items = new Collection([1, 2, 3])->map(fn($n) => $n * 2)->toArray();

// Property access too
$length = new SplFixedArray(10)->count();

// Array access
$first = new ArrayObject(['a', 'b', 'c'])[0];

This is the kind of paper-cut fix that makes a language more pleasant to use every day. Every PHP developer has hit this — you create an object, chain a method, get a syntax error, then add parentheses and grumble.

Significance: Fluency

Language design is about defaults. The old behavior — requiring parentheses to chain on new — was an arbitrary parser limitation that tripped up developers constantly. Removing it makes PHP's syntax do what you'd naturally expect.