PHP TypeLang Help

@require-extends

A trait can be written to depend on the class it will eventually be mixed into — calling methods or reading properties that the trait itself never declares. @require-extends makes that dependency explicit: it states that the trait may only be used inside a class extending the given type, so a static analyzer can verify every such use site and let the trait reference the parent's members without redeclaring or stubbing them.

"@require-extends" <Type> [ <Description> ]

Parsing a @require-extends tag produces a RequireExtendsTag instance exposing $type — the TypeNode naming the required parent class — plus the $name and $description every tag carries.

abstract class RequireInheritanceTag extends TypedTag {} final class RequireExtendsTag extends RequireInheritanceTag { // inherits the computed TypeNode $type // getter from TypedTag; adds nothing. }

See also @require-implements for constraining a trait to classes implementing a given interface instead.

Neither PSR-19 nor phpDocumentor defines this tag. Its real-world spellings are vendor-prefixed: Psalm's @psalm-require-extends and PHPStan's @phpstan-require-extends (covered in PHPStan's PHPDoc basics). This component recognizes the bare @require-extends spelling shown above as the tool-agnostic equivalent of both.

05 July 2026