Property Hooks https://www.garfieldtech.com/ en Property hooks in practice https://www.garfieldtech.com/blog/property-hooks-in-practice <article data-history-node-id="328" role="article" class="node node--type-story node--promoted node--view-mode-teaser clearfix"> <header> <h2 class="node__title"> <a href="/blog/property-hooks-in-practice" rel="bookmark"><span class="field field--name-title field--type-string field--label-hidden">Property hooks in practice</span> </a> </h2> <div class="node__meta"> <article class="profile"> </article> <span> Submitted by <span class="field field--name-uid field--type-entity-reference field--label-hidden"><span>Larry</span></span> on <span class="field field--name-created field--type-created field--label-hidden">22 October 2024 - 11:32pm</span> </span> </div> </header> <div class="node__content clearfix"> <div class="clearfix text-formatted field field--name-body field--type-text-with-summary field--label-hidden field__item"><p>Two of the biggest features in the upcoming PHP 8.4 are property hooks and asymmetric visibility (or "aviz" for short). Ilija Tovilo and I worked on them over the course of two years, and they're finally almost here!</p> <p>OK, so now what?</p> <p>Rather than just reiterate what's in their respective RFCs (there are many blog posts that do that already), today I want to walk through a real-world application I'm working on as a side project, where I just converted a portion of it to use hooks and aviz. Hopefully that will give a better understanding of the practical benefits of these tools, and where there may be a rough edge or two still left.</p> <p>One of the primary use cases for hooks is to not use them: They're there in case you need them, so you don't need to make boilerplate getter/setter methods "just in case." However, that's not their only use. They're also really nice when combined with interface properties, and delegation. Let's have a look.</p></div> <div class="node__links"> <ul class="links inline"><li class="node-readmore"><a href="/blog/property-hooks-in-practice" rel="tag" title="Property hooks in practice" hreflang="en">Read more<span class="visually-hidden"> about Property hooks in practice</span></a></li></ul> </div> </div> </article> Wed, 23 Oct 2024 04:32:47 +0000 Larry 328 at https://www.garfieldtech.com