PHP TypeLang Help

@param-closure-this

The @param-closure-this tag documents what $this refers to inside a Closure parameter. A @param on that same parameter already describes the closure's own signature — the arguments it receives and what it returns — but says nothing about the object it will be bound to when the closure is eventually invoked through Closure::bindTo(), Closure::call(), or an equivalent internal rebinding. Without this tag, code inside the closure that reads $this has no documented type to check against.

"@param-closure-this" <Type> <Variable> [ <Description> ]

Parsing a @param-closure-this tag produces a TypedVariableTag instance exposing:

  • $type — the documented TypeNode that $this is bound to.

  • $variable — the closure parameter's name, without the leading $.

final class ParamClosureThisTag extends TypedVariableTag { // Own constructor adds nothing; both // properties below are inherited from // TypedVariableTag (and its parent TypedTag): public TypeNode $type { get => $this->statement->type; } public readonly string $variable; }

This is the same shape as @param, just aimed at the closure's binding rather than its signature.

PHPStan documents @param-closure-this alongside its other callable-related tags; Psalm has no equivalent.

05 July 2026