Atomic types

Atomic types are the basic building block of all type information used in Psalm. Multiple atomic types can be combined, either with union types or intersection types. Psalm allows many different sorts of atomic types to be expressed in docblock syntax:

Scalar types

Object types

Array types

Callable types

Value types

Magical types

  • key-of<Foo\Bar::ARRAY_CONST>
  • value-of<Foo\Bar::ARRAY_CONST>
  • T[K]

Other

  • iterable - represents the iterable pseudo-type. Like arrays, iterables can have type parameters e.g. iterable<string, Foo>.
  • void - can be used in a return type when a function does not return a value.
  • empty - a type that represents a lack of type - not just a lack of type information (that's where mixed is useful) but where there can be no type. A good example is the type of the empty array []. Psalm types this as array<empty, empty>.
  • mixed represents a lack of type information. Psalm warns about mixed when the totallyTyped flag is turned on.
  • resource represents a PHP resource.
  • no-return is the 'return type' for a function that can never actually return, such as die(), exit(), or a function that always throws an exception. It may also be written as never-return or never-returns, and is also known as the bottom type.