Tag reference
@param-later-invoked-callable
The @param-later-invoked-callable tag marks a callable argument that is
kept by the function or method and invoked only after the call has already
returned — an event listener being registered, a callback stashed for a
future tick of an event loop, and similar patterns. This matters to static
analysis for the opposite reason
@param-immediately-invoked-callable
does: variables captured by reference into the callback cannot be trusted
to hold any particular value once the outer call returns, since the
callback body has not actually run yet, and the function storing it cannot
be assumed pure just because the callback itself might be.
Grammar
"@param-later-invoked-callable" <Variable> [ <Description> ]"@phpstan-param-later-invoked-callable" <Variable> [ <Description> ]Examples
/** * @param callable(Event): void $listener * @param-later-invoked-callable $listener */function on(string $event, callable $listener): void/** * @param-later-invoked-callable $callback Invoked once the response * arrives, which may be long after * this method returns. */function then(callable $callback): staticNames by platform
- phpstan
@phpstan-param-later-invoked-callable- standard
@param-later-invoked-callable
Parsing a @param-later-invoked-callable tag produces a VariableTag
instance exposing $variable: the parameter’s name, without the leading
$. The type of the callable itself is whatever the parameter’s own
@param already declares.
abstract class ParamInvokedCallableTag extends VariableTag {}
final class ParamLaterInvokedCallableTag extends ParamInvokedCallableTag{ // Adds nothing of its own; $variable is // declared on the parent VariableTag.}The opposite case — a callable guaranteed to run before the call returns — is documented with @param-immediately-invoked-callable instead.
PHPStan documents @param-later-invoked-callable
alongside its other callable-related tags; Psalm has no equivalent.