Class PHPStan\Reflection\Assertions

final

Collection of @phpstan-assert annotations on a function or method. PHPStan supports type assertions via PHPDoc annotations:

  • @phpstan-assert Type $param — narrows the parameter type unconditionally
  • @phpstan-assert-if-true Type $param — narrows when the method returns true
  • @phpstan-assert-if-false Type $param — narrows when the method returns false This class collects all such assertions and provides methods to retrieve them by condition type. It also handles negation: an @phpstan-assert-if-true assertion is automatically negated and included in the getAssertsIfFalse() result. Returned by ExtendedMethodReflection::getAsserts() and FunctionReflection::getAsserts().
Methods