0003 Filters and actions
Events report what happened. Hooks let extensions change how it happens.
Filters transform a value through a priority-ordered pipeline (
applyFilters(name, value, ...args)).Actions run callbacks at a named point (
doAction(name, ...args)).Priority defaults to 10 (lower runs first) and ties keep registration order, like WordPress.
Every registration has a namespace and a disposer. A plugin's hooks are removed when it is disposed.
A throwing callback is isolated and reported; the pipeline continues with the last good value. Strict mode rethrows. Recursion is bounded.
Hooks are synchronous inside transactions and rendering; async variants serve service pipelines.
Names and signatures are declared by augmenting
FilterHooksandActionHooks, so typed hooks are checked at compile time; undeclared names remain usable withunknowntypes.