Tag reference
@mixin
Some classes expose members they never declare themselves, delegating to
another object at runtime through __call, __get, or similar magic
methods. PHP’s own type system has no way to express that delegation, so an
IDE or static analyzer sees only the handful of methods actually written on
the class. @mixin tells it to also treat every public method and property
of the referenced type as available, restoring autocomplete and type
checking for code that would otherwise only work by accident at runtime.
Grammar
"@mixin" <Type> [ <Description> ]"@phan-mixin" <Type> [ <Description> ]Examples
/** * @mixin Connection */class QueryBuilder{ public function __call(string $name, array $arguments): mixed { return $this->connection ->$name(...$arguments); }}Names by platform
- phan
@phan-mixin- standard
@mixin
Parsing a @mixin tag produces a MixinTag instance:
final class MixinTag extends TypedTag{ // adds nothing of its own: `$type`, `$name` // and `$description` are inherited.}It exposes $type — the TypeNode naming the
delegated-to type — along with the $name and
$description every tag carries.
@mixin is not a phpDocumentor or PSR tag: it originates
as a shared PHPStan
and Psalm
convention, and this library follows that same, more
widely used, spelling.