PHP TypeLang Help

@phpstan-assert

The @phpstan-assert tag asserts that an argument or variable is narrowed to a given type after the call, defined by PHPStan. It has -if-true and -if-false siblings for assertions that only hold when a boolean-returning function returns a particular value.

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

Parsing a @phpstan-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 @phan-assert, which restate the same assertion for their respective tools.

Documented by PHPStan.

08 July 2026