What's New in PHP 8.4

PHP 8.4 continues the language's evolution with features that bring it closer to modern programming paradigms. The headline feature is property hooks, which allow you to define getter and setter logic directly on class properties.

Property Hooks

Property hooks eliminate the need for verbose getter and setter methods in many cases. You can now write public string $name { get => $this->name; set => ucfirst($value); } directly in your class definition.

Asymmetric Visibility

You can now declare different visibility for reading and writing a property: public protected(set) string $status means the property is readable publicly but can only be set from within the class or its children.