# Adding assertions Psalm has three docblock annotations that allow you to specify that a function verifies facts about variables and properties: - `@psalm-assert` (used when throwing an exception) - `@psalm-assert-if-true`/`@psalm-assert-if-false` (used when returning a `bool`) A list of acceptable assertions [can be found here](assertion_syntax.md). ## Examples If you have a class that verified its input is an array of strings, you can make that clear to Psalm: ```php isValid(); } /** * @psalm-assert-if-false B $a */ function isInvalidB(A $a) : bool { return $a instanceof B || !$a->isValid(); } function takesA(A $a) : void { if (isValidB($a)) { $a->bar(); } if (isInvalidB($a)) { // do something } else { $a->bar(); } $a->bar(); //error } ``` As well as getting Psalm to understand that the given data must be a certain type, you can also show that a variable must be not null: ```php