PHP TypeLang Help

@phpstan-assert-if-true

The @phpstan-assert-if-true tag asserts the given type when the function returns true, defined by PHPStan. It is one of the @phpstan-assert family of narrowing tags.

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

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

final class AssertIfTrueTag extends TypedVariableTag {}

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

Documented by PHPStan.

08 July 2026