Skip to content

Tag reference

@assert-if-false

The @assert-if-false tag asserts the given type for a subject, but only when the function returns false.

Grammar

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

Examples

Narrowing when the check returns false.
/**
* @phan-assert-if-false string $value
*/
function isNotString(mixed $value): bool

Names by platform

phan
@phan-assert-if-false
phpstan
@phpstan-assert-if-false
psalm
@psalm-assert-if-false