@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> <Subject> [ <Description> ]
Parsing a @phpstan-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 @psalm-assert-if-true and @phan-assert-if-true, which restate the same assertion for their respective tools.
Documented by PHPStan.
12 September 2026