PHP 8.4 New Features: Property Hooks, Asymmetric Visibility & More

PHP 8.4 New Features: Property Hooks, Asymmetric Visibility & More
Blog 2 Min. read
PHP 8.4 shipped in November 2024 with significant developer experience improvements. Property hooks, asymmetric visibility, and four new array functions are the highlights.

What Shipped in PHP 8.4

PHP 8.4 was released in November 2024. Rather than sweeping syntax changes, it focused on developer experience improvements that eliminate common boilerplate. Three features stand out.

1. Property Hooks

Before PHP 8.4, custom get/set logic required separate accessor methods. PHP 8.4 lets you write the same thing inline:

class User {
    public string $name {
        set(string $value) => $this->name = trim($value);
    }
}

The boilerplate reduction is substantial — especially in Laravel models and DTOs where accessors are common.

2. Asymmetric Visibility

PHP 8.1's readonly made properties fully immutable. PHP 8.4 adds per-access-level visibility:

class Order {
    public private(set) int $status = 0;
    // Readable from outside, writable only within Order
}

This is the pattern previously approximated with readonly plus workarounds. Now it is first-class syntax.

3. New Array Functions

PHP 8.4 adds four long-awaited array functions:

  • array_find() — returns the first element matching a predicate
  • array_find_key() — returns the key of the first match
  • array_any() — true if at least one element matches
  • array_all() — true if all elements match

These replace the verbose array_filter + reset or manual foreach patterns that were standard before.

Should You Upgrade?

PHP 8.1 security support ended in December 2025. PHP 8.0 and below no longer receive any updates. Running an older version in production means running known, unpatched vulnerabilities. PHP 8.4-ready hosting? Check our web hosting plans or cloud servers.

Will upgrading to PHP 8.4 break my existing code?

PHP 8.4 is conservative on breaking changes. The most notable is that some implicit null conversions now throw errors instead of deprecation warnings. Most applications migrate cleanly, but always test in a staging environment before deploying to production.

Are PHP 8.4 property hooks compatible with Laravel and Eloquent?

Yes. Property hooks are standard PHP syntax and fully compatible with Laravel. They can coexist with Eloquent accessors and mutators without conflict — they operate at different layers of the stack.

How much faster is PHP 8.4 compared to PHP 8.3?

PHP 8.4 delivers roughly 3-8% throughput improvement over 8.3 through JIT enhancements and internal optimisations. Small on paper, but meaningful for compute-heavy applications running at scale.

PHP 8.4 property hooks asymmetric visibility array_find PHP new features

EuroVDC

Host Your Website with Confidence

NVMe SSD storage · Free SSL · cPanel included

View Web Hosting Plans

Did you find this content useful?

People found it useful

Share on Social Media

PHP 8.4 New Features: Property Hooks, Asymmetric Visibility & More