vincent @ workstation : ~/blog/php-8-4-property-hooks-asymmetric-visibility $ cat posts/php-8-4-property-hooks-asymmetric-visibility.md

PHP 8.4: property hooks, asymmetric visibility, and the rest

Three PHP 8.4 additions that actually change how you write code day to day.

PHP 8.4 shipped late 2024 and remains, at the time of writing (April 2026), the latest stable release — 8.5 is in RC. Here are the additions that have actually changed how I write PHP day to day.

## property hooks

The most visible change. You can finally declare a getter/setter directly on a property, without ceremony:

final class User
{
    public function __construct(
        public string $firstName,
        public string $lastName,
    ) {}

    public string $fullName {
        get => "{$this->firstName} {$this->lastName}";
    }
}

$u = new User('Vincent', 'Veysset');
echo $u->fullName; // "Vincent Veysset"

No more getFullName() methods everywhere: you access the property, the hook computes on the fly. And it’s compatible with constructor promotion, so you keep the one-line declaration.

## asymmetric visibility

You can now declare a property public for reading but private for writing. Innocuous on paper — in practice, the end of a mountain of boilerplate:

final class Order
{
    public private(set) string $status = 'pending';

    public function ship(): void
    {
        $this->status = 'shipped';
    }
}

$o = new Order();
echo $o->status;       // ok, public read
$o->status = 'foo';    // error: private write

## new array_* functions

array_find, array_find_key, array_any, array_all — small but welcome: we finally get the helpers we’ve all written ten times over.

$users = [/* ... */];
$admin = array_find($users, fn($u) => $u->role === 'admin');
$hasAdmin = array_any($users, fn($u) => $u->role === 'admin');

## conclusion

PHP 8.4 doesn’t revolutionize the language, but smooths out a few rough edges that had been lingering. Combined with declare(strict_types=1), readonly classes, enums, and a recent Symfony/Laravel, you get a productive environment that holds up in architecture reviews.