Skip to content

Tag reference

@phan-closure-scope

The @phan-closure-scope tag binds the type of $this inside a Closure, letting Phan analyze the closure’s body as though it were bound to an instance of the given class.

Grammar

"@phan-closure-scope" <Type> [ <Description> ]
"@phanclosurescope" <Type> [ <Description> ]

Examples

Analyzing a closure as if bound to a class.
/**
* @phan-closure-scope Order
*/
$total = function (): int {
return $this->amount;
};

Names by platform

phan
@phan-closure-scope@phanclosurescope

Parsing a @phan-closure-scope tag produces a PhanClosureScopeTag instance, carrying the parsed $type alongside the $name and optional $description every Tag already provides.

final class PhanClosureScopeTag extends TypedTag {}

Defined by Phan’s Annotating Your Source Code wiki.