Quick reference of all type annotations supported by Psalm 7. Useful when writing stubs and handlers.
Source of truth: vendor/vimeo/psalm/src/Psalm/Internal/Type/TypeTokenizer.php (PSALM_RESERVED_WORDS) and vendor/vimeo/psalm/src/Psalm/DocComment.php (PSALM_ANNOTATIONS).
All of the above also accept a @psalm- prefix (e.g. @psalm-param) for advanced type syntax that phpDocumentor can’t parse. PHPStan prefix (@phpstan-param, etc.) is also recognized.
Assertions
Annotation
When it applies
@psalm-assert Type $param
Function returns normally
@psalm-assert !Type $param
Function returns normally
@psalm-assert-if-true Type $param
Function returns true
@psalm-assert-if-true !Type $param
Function returns true
@psalm-assert-if-false Type $param
Function returns false
@psalm-assert-if-false !Type $param
Function returns false
Negated assertions (!Type) assert the param is not of the given type. Common examples: !null, !false, !string.
Output Type Narrowing
Annotation
Notes
@psalm-param-out Type $param
By-ref param type after call
@psalm-self-out Type
$this type changes after call
@psalm-this-out Type
Same as self-out
@psalm-if-this-is Type
Precondition on $this type
Suppression and Debugging
Annotation
Notes
@psalm-suppress IssueType
Suppress a specific issue
@psalm-trace
Print inferred type (debug)
@psalm-check-type
Assert inferred type matches
@psalm-check-type-exact
Assert exact type match
@psalm-ignore-var
Ignore @var in same docblock
@psalm-ignore-nullable-return
Suppress nullable return issues
@psalm-ignore-falsable-return
Suppress false return issues
@psalm-ignore-variable-method
Ignore variable method in dead code
@psalm-ignore-variable-property
Ignore variable property in dead code
Purity and Mutability
Annotation
Scope
@psalm-pure
Function: output depends only on input
@psalm-impure
Explicitly marks side effects
@psalm-mutation-free
Method: no mutation of any state
@psalm-external-mutation-free
Method: may mutate $this, nothing external
@psalm-immutable
Class: all properties readonly, all methods mutation-free
@psalm-mutable
Class: explicitly not immutable (default)
Readonly
Annotation
Notes
@psalm-readonly / @readonly
Property only writable in constructor
@psalm-allow-private-mutation
Readonly but writable in private methods
@psalm-readonly-allow-private-mutation
Shorthand for both
Sealing
Annotation
Notes
@psalm-seal-properties
No undeclared __get/__set access
@psalm-seal-methods
No undeclared __call access
@psalm-no-seal-properties
Reverse seal
@psalm-no-seal-methods
Reverse seal
Visibility Overrides
Annotation
Notes
@psalm-override-property-visibility
Override property visibility
@psalm-override-method-visibility
Override method visibility
Class-Level
Annotation
Notes
@psalm-consistent-constructor
All child constructors match signature
@psalm-consistent-templates
Template params stay consistent in children
@psalm-inheritors
Restrict which classes can extend
@psalm-require-extends ClassName
Trait only usable in subclasses of ClassName
@psalm-require-implements Interface
Trait only usable in implementors
@psalm-api / @api
Mark as used (suppress unused code detection)
@psalm-internal Namespace
Restrict usage to a namespace
Generators and Scope
Annotation
Notes
@psalm-yield TValue
On a class/interface: declares what type a generator receives when yielding this object. Used for Promise/Deferred patterns – TValue must be a @template param. Psalm resolves it via template expansion
@psalm-variadic
On a function: marks it as accepting unlimited arguments even without ... in the signature. Useful for functions that rely on func_get_args() internally
@psalm-scope-this Type
On a statement block: overrides the type of $this for the enclosed code. Useful for closures bound to other objects at runtime (e.g. Closure::bind(), Laravel macros)
Stub-Specific
Annotation
Notes
@psalm-stub-override
Safety guard for stubs: asserts that the annotated class/method exists in the original codebase. Psalm throws an error if no original counterpart is found, catching typos and stale stubs early
Other
Annotation
Notes
@no-named-arguments
Disallow named arguments on this function
Taint Analysis Annotations
Annotation
Notes
@psalm-taint-source TaintType
Mark return as taint source (e.g. html, sql, shell)