Skip to content

Tag reference

@psalm-scope-this

The @psalm-scope-this tag binds the type of $this inside a Closure, letting Psalm type-check the closure body as if it were a method of the given class.

Grammar

"@psalm-scope-this" <Type> [ <Description> ]

Examples

Checking a closure as a method of a class.
/**
* @psalm-scope-this Order
*/
$total = function (): int {
return $this->amount;
};

Names by platform

psalm
@psalm-scope-this

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

final class PsalmScopeThisTag extends TypedTag {}