wrapCallable.php
Table of Contents
Functions
- wrapCallable() : callable
- Wraps a callable to apply middleware/decorators before/after execution.
Functions
wrapCallable()
Wraps a callable to apply middleware/decorators before/after execution.
wrapCallable(callable $callable, callable $wrapper) : callable
This function allows you to decorate a callable with custom logic that executes before and/or after the original callable is invoked. The wrapper receives the original callable and its arguments, giving complete control over execution flow.
The wrapper callable receives:
- First argument: The original callable to invoke
- Remaining arguments: The arguments passed to the wrapped callable
The wrapper is responsible for calling the original callable and returning its result. This enables use cases like logging, timing, error handling, caching, etc.
Parameters
- $callable : callable
-
The original callable to wrap
- $wrapper : callable
-
A callable that receives the original callable and args. Signature:
function($original, ...$args)
Tags
Return values
callable —A new wrapped callable that applies the wrapper logic