---
title: "Rethinking do_action(): Events as objects, hooks as class names"
url: https://daily.dev/posts/rethinking-do-action-events-as-objects-hooks-as-class-names-oxkbbiobj
source_url: https://developer.wordpress.org/news/2026/08/rethinking-do_action-events-as-objects-hooks-as-class-names
type: article
source: "WordPress Developer"
published: 2026-08-03T21:10:34.106Z
updated: 2026-08-04T00:18:05.347Z
tags: ["architecture", "php", "wordpress", "react-hooks"]
reading_time: 13
upvotes: 2
comments: 0
language: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Rethinking do_action(): Events as objects, hooks as class names

**[WordPress Developer](https://daily.dev/sources/wordpressdev)** · 13 min read · 2 upvotes · 0 comments

## Summary

A technique for improving WordPress action hooks by passing typed event objects instead of loose positional arguments. Using `do_action($event::class, $event)` gives you namespaced hook names via fully-qualified class names, IDE autocomplete and static analysis on payloads, and filter-like mutation through mutable object properties — all without any new dependencies. The approach mirrors the PSR-14 event dispatcher pattern and works with WordPress's existing hook API. The post covers event class design with readonly vs mutable properties, observer vs mutator listener patterns, and the tradeoffs between using class names vs fixed strings as hook identifiers.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://developer.wordpress.org/news/2026/08/rethinking-do_action-events-as-objects-hooks-as-class-names>

## Similar posts on daily.dev

- [Beyond Fat Controllers: Mastering Event-Driven Decoupling in Laravel](https://daily.dev/posts/beyond-fat-controllers-mastering-event-driven-decoupling-in-laravel-rkl3ao0vg) · CodeCraft Diary · 1 upvotes · 0 comments

---

Tags: [#architecture](https://daily.dev/tags/architecture), [#php](https://daily.dev/tags/php), [#wordpress](https://daily.dev/tags/wordpress), [#react-hooks](https://daily.dev/tags/react-hooks)

[View this post on daily.dev](https://daily.dev/posts/rethinking-do-action-events-as-objects-hooks-as-class-names-oxkbbiobj)
