What are Property Hooks in PHP 8.4, and how do they change the traditional getter/setter pattern?

Last updated 15 June 2026

  • Property Hooks attach get and/or set logic directly to a property declaration. Callers still use $obj->name and the hook runs transparently.

  • They replace boilerplate getName()/setName() pairs plus a private field, keeping validation and computed values next to the property.

  • A property with only a get hook and no backing storage is virtual (computed on read). Careless self-access inside its own hook can recurse.

  • https://www.php.net/manual/en/language.oop5.property-hooks.php
  • https://doganoo.medium.com/property-hooks-rfc-for-php-8-4-7bc26f9be989
  • https://dineshstack.com/en/php-84-property-hooks-the-feature-that-changes-everything
  • https://stitcher.io/blog/a-year-of-property-hooks
  • https://www.zend.com/blog/php-8-4-property-hooks
  • https://stitcher.io/blog/new-in-php-84
  • https://dogan-ucar.de/en/property-hooks-rfc-for-php-8-4/
  • https://wiki.php.net/rfc/property-hooks
All PHP interview questions