Member-only story

Recap PHP Property Hooks in 2025

Doğan Uçar
3 min readFeb 7, 2025

--

PHP Property Hooks
Abstract PHP Property Hooks

Last year in April, I wrote about the Property Hooks RFC added to PHP 8.4 and my thoughts about it. The blog post appeared one day after the RFC was accepted and that is why the post was more theoretical. Now, almost two month after release, I want to address this topic again and want to share my thoughts after working with Property Hooks in practice. I want also express my opinion regarding to Property Hooks since I ended my last post with:

Since the RFC includes declaring properties, I think it is worth to give it a chance. I know that many programmers will have a pain in the stomach juggling with properties publicly, but technically, the getters and setters are not away — they are just handled differently.
Property Hooks RFC for PHP 8.4

Understanding Property Hooks

A short profiling: what are Property Hooks? The feature allows developers to define custom behavior directly within class properties, shrinking code and reducing the need for boilerplate getter and setter methods.

Property Hooks enable the definition of get and set operations within a property’s declaration. This approach offers a more intuitive and concise method to manage property access and mutation, enhancing code readability and maintainability.

The get Hook

--

--

Doğan Uçar
Doğan Uçar

Written by Doğan Uçar

Software Engineer, PHP/Laminas (Zend), Backend, Cloud, Freelancer & CEO, Open Source Contributor

No responses yet