Hook handlers can be registered in a variety of formats, some of which stem from a time when PHP had no support for closures. Supporting all the different forms is confusing and leads to brittle code.
In the future, acceptable forms for hook handlers should be reduced to:
- a callable (in the form of a string, an array, or a closure)
- an object, which is expected to have a public "on" method that matches the hook name.
- an array containing an object spec in the "handler" key, for use with ExtensionRegistry.
The following forms should be disallowed:
- False values (used as dummies in testing). Use HookContainer::NOOP instead.
- Using a qualified method name in a two-element callable array, e.g. [ 'MyClass', 'MyClass::onSomeHook' ].
- Callable arrays with extra data, e.g. [ 'MyClass', 'MyClass::onSomeHook', 1, 2, 3 ].
- Objects wrapped in an array, e.g. [ $handlerObject ] instead of just $handlerObject.
- Callables nexted in arrays, e.g. [ [ 'MyClass', 'MyClass::onSomeHook' ] ].