The hook handler alter the behavior of original handler passed by call
or call_sync
. Its implementation allos multiple execution patterns:
- Execute code before and after the original handler
- Alter the arguments arguments
- Return a modified or different value
- Stop the handler execution pipeline
When the handler defines 1 argument, it can only access and modify the interception point arguments.
When the handler defines 2 arguments, it get access to the original handler or the handler returned by the previous hook. It can then decide to return it, execute it or even return an alternative handler. It can also prevent other hooks from being executed by returning null
.