PHP TypeLang Help

@phan-assert

The @phan-assert tag asserts that an argument or variable is narrowed to a given type after the call returns. Phan documents it together with its @phan-assert-if-true and @phan-assert-if-false siblings — see @phan-assert-if-true and @phan-assert-if-false — as part of the same assertion family.

"@phan-assert" <Type> <Variable> [ <Description> ]

Parsing a @phan-assert tag produces an AssertTag instance, carrying the asserted $type and $variable alongside the $name and optional $description every Tag already provides.

final class AssertTag extends TypedVariableTag {}

The same AssertTag is produced by @psalm-assert and @phpstan-assert, which restate the same assertion for their respective tools.

Defined by Phan; see the "Assertions" section of Phan's Annotating Your Source Code wiki.

08 July 2026