PHP 8.4 Features in PHP

From the PHP cheat sheet ยท PHP 8 Features ยท verified Jul 2026

PHP 8.4 Features

Property hooks, asymmetric visibility, new array helpers

php
// Property hooks (PHP 8.4) โ€” get/set without a backing function
class User {
    public string $fullName {
        get => "{$this->first} {$this->last}";
        set => trim($value);
    }

    public function __construct(
        public string $first,
        public string $last,
    ) {}
}

// Asymmetric visibility (PHP 8.4)
class Post {
    public private(set) string $id = '';
    public protected(set) int $views = 0;
}

// New array functions (PHP 8.4)
$first = array_find($users, fn($u) => $u->isActive);
$any = array_any($users, fn($u) => $u->isAdmin);
$all = array_all($users, fn($u) => $u->isVerified);

// Chain new without parens (PHP 8.4)
$slug = new Slugger()->slugify($title);
๐Ÿ’ก Property hooks replace boilerplate getter/setter pairs
๐Ÿ“Œ Asymmetric visibility = public read, restricted write
โšก array_find / array_any / array_all are finally built-in
๐ŸŸข `new Foo()->bar()` no longer needs the extra parentheses
php8.4featuresmodern

More PHP tasks

Back to the full PHP cheat sheet