← All news
PHP 8.4: Property Hooks, Asymmetric Visibility and More
PHP 8.4, released on 21 November 2024, introduced property hooks, asymmetric visibility, the #[\Deprecated] attribute and new array helper functions.
PHP 8.4.0 was released on 21 November 2024 and remains a supported branch today (its latest security release, 8.4.27, fixes PHP2Shell). Key additions:
- Property hooks – define
get/setlogic directly on a property, removing much getter/setter boilerplate. - Asymmetric visibility – e.g.
public private(set) string $name;lets a property be publicly readable but only privately writable. #[\Deprecated]attribute – mark your own functions, methods and constants as deprecated with native engine warnings.- New array functions –
array_find(),array_find_key(),array_any()andarray_all(). newwithout parentheses –new MyClass()->method()now works without wrapping parentheses.- Lazy objects support in the engine and a new DOM API with HTML5 parsing.
The release also deprecates implicitly nullable parameter types (function f(Type $x = null)), a change that produces deprecation notices in many older codebases.
Source: php.net PHP 8.4 announcement
Seeing a flood of 8.4 deprecation notices in an older app? RescuePHP can clean them up and get your code ready for current PHP.