Tag reference
@implements
The same problem @extends solves for a generic parent class shows up when a
class implements a generic interface: PHP’s implements keyword can name
the interface but cannot supply its type parameters. @implements documents
those type arguments, e.g. an ArrayAccess implementation that is actually
keyed and valued with specific types rather than mixed.
Grammar
"@implements" <Type> [ <Description> ]"@phpstan-implements" <Type> [ <Description> ]"@psalm-implements" <Type> [ <Description> ]"@template-implements" <Type> [ <Description> ]Examples
/** * @implements ArrayAccess<int, User> */final class UserList implements ArrayAccess {}/** * @implements RepositoryInterface<Order> */final class OrderRepository implements RepositoryInterface {}Names by platform
- phpstan
@phpstan-implements- psalm
@psalm-implements- standard
@implements@template-implements
Parsing an @implements tag produces a tag exposing $type — the TypeNode
naming the interface together with its type arguments — plus the $name and
$description common to every tag.
final class ImplementsTag extends InheritanceTag{ // adds nothing of its own: the // `public readonly TypeNode $type` is // inherited from TypedTag, which in turn // keeps the protected TypeReference // $statement it was built from.}The alias @template-implements is
recognized as well; it parses to the same kind of tag as
@implements. See also @extends for the equivalent
tag used on generic parent classes.
@implements is not a phpDocumentor or PSR-19 tag. It is a generics
convention introduced independently by
PHPStan and
Psalm,
and this component follows their lead rather than any formal
standard.