Skip to content

Tag reference

@self-out

The @self-out tag documents the refined type of $this after a method call, letting callers see a narrower object type than the one they started with.

Grammar

"@phpstan-self-out" <Type> [ <Description> ]
"@self-out" <Type> [ <Description> ]
"@phpstan-this-out" <Type> [ <Description> ]
"@psalm-self-out" <Type> [ <Description> ]
"@psalm-this-out" <Type> [ <Description> ]

Examples

The type of the object after the call.
/**
* @phpstan-self-out self<T>
*/
public function add(mixed $item): void

Names by platform

phpstan
@phpstan-self-out@phpstan-this-out
psalm
@psalm-self-out@psalm-this-out