PHP TypeLang Help

@psalm-assert-if-true

The @psalm-assert-if-true tag asserts the given type for an argument or variable when the function returns true. It is defined by the static analyzer Psalm, alongside @psalm-assert.

"@psalm-assert-if-true" [ "!" | "=" | "!=" ] <Type> <Subject> [ <Description> ]

Parsing a @psalm-assert-if-true tag produces an AssertIfTrueTag instance, carrying the asserted $type, the $subject it is asserted of and the $operator relating them, alongside the $name and optional $description every Tag already provides.

final class AssertIfTrueTag extends AssertionTag {}

The same AssertIfTrueTag is produced by @phpstan-assert-if-true and @phan-assert-if-true, which restate the same assertion for their respective tools.

See Psalm's supported annotations.

12 September 2026