Skip to content

PHP 8.4: Property Hooks and Asymmetric Visibility

PHP 8.4: Property Hooks and Asymmetric Visibility
Blog 2 min read

PHP 8.4 for developers: property hooks, asymmetric visibility, new array functions and the new DOM API, with upgrade tips and hosting notes.

PHP 8.4 was released in November 2024. Its headline features make object code shorter and clearer: property hooks and asymmetric visibility. A handful of smaller additions round out the release, and PHP 8.5 followed in November 2025, so teams often upgrade through 8.4 on the way.

Property hooks

A property can now carry its own get and set logic, without writing separate getter and setter methods.

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

Hooks validate or transform values at the point of assignment and keep the public surface a plain property.

Asymmetric visibility

You can now give a property different visibility for reading and writing, for example public read and private write.

class Order {
    public private(set) string $status = 'new';
}

Callers can read $order->status but only the class changes it. That replaces many read-only getters.

Other additions worth knowing

FeatureWhat it gives you
array_find, array_any, array_allSearch and test arrays without a manual loop
new without extra parenthesesnew Foo()->bar() works directly
New HTML5-capable DOM APIBetter parsing of modern HTML
#[\Deprecated] attributeMark your own functions as deprecated
Implicit nullable types deprecatedWrite ?string $x = null explicitly

Upgrade tips

  1. Run your test suite on 8.4 and read the deprecation notices.
  2. Update frameworks and packages first, since most added 8.4 support already.
  3. Fix implicit nullable parameter types, the most common warning.
  4. Test on staging with the same extensions as production.

Where to run it

Standard sites run on web hosting when the panel lets you pick the PHP version. When you need custom extensions, Composer-managed deployments or background workers, use a cloud server. Newer PHP versions are also faster for WordPress, as covered in WordPress hosting in Europe.

Frequently asked questions

Are property hooks a replacement for getters and setters?

They cover simple cases cleanly. Keep methods when the logic needs several parameters or a name that explains the action.

Will my old code break on 8.4?

Mostly it runs, with deprecation notices to fix. Check the implicit nullable parameter notices first.

How long is PHP 8.4 supported?

Active support runs about two years from release, with security fixes for a further two. Check php.net for the exact dates.

php 8.4 property hooks visibility hosting eurovdc

EuroVDC

Host Your Website with Confidence

NVMe SSD storage · Free SSL · DirectAdmin panel

View Web Hosting Plans

Was this article helpful?

– people found this helpful

Share on Social Media

PHP 8.4: Property Hooks and Asymmetric Visibility