Skip to content

Tag reference

@assert

The @assert tag asserts that the given subject is narrowed to the type it carries once the call returns.

Grammar

"@phan-assert" [ ( "!=" | "!" | "=" ) ] <Type> <AssertSubject> [ <Description> ]
"@phpstan-assert" [ ( "!=" | "!" | "=" ) ] <Type> <AssertSubject> [ <Description> ]
"@psalm-assert" [ ( "!=" | "!" | "=" ) ] <Type> <AssertSubject> [ <Description> ]

Examples

Narrowing the argument after the call.
/**
* @phan-assert string $value
*/
function assertString(mixed $value): void

Names by platform

phan
@phan-assert
phpstan
@phpstan-assert
psalm
@psalm-assert