Skip to content

Documentation Atomic types
Type to start searching
    GitHub
    Psalm docs
    • Home
    • Running Psalm
      • Installation
      • Configuration
      • Plugins
        • Using plugins
        • Authoring plugins
        • How Psalm represents types
      • Command line usage
      • IDE support
      • Dealing with code issues
      • Issue Types
        • Overview
        • AbstractInstantiation
        • AbstractMethodCall
        • AmbiguousConstantInheritance
        • ArgumentTypeCoercion
        • AssignmentToVoid
        • CheckType
        • CircularReference
        • ClassMustBeFinal
        • ComplexFunction
        • ComplexMethod
        • ConfigIssue
        • ConflictingReferenceConstraint
        • ConstantDeclarationInTrait
        • ConstructorSignatureMismatch
        • ContinueOutsideLoop
        • DeprecatedClass
        • DeprecatedConstant
        • DeprecatedFunction
        • DeprecatedInterface
        • DeprecatedMethod
        • DeprecatedProperty
        • DeprecatedTrait
        • DirectConstructorCall
        • DocblockTypeContradiction
        • DuplicateArrayKey
        • DuplicateClass
        • DuplicateConstant
        • DuplicateEnumCase
        • DuplicateEnumCaseValue
        • DuplicateFunction
        • DuplicateMethod
        • DuplicateParam
        • DuplicateProperty
        • EmptyArrayAccess
        • ExtensionRequirementViolation
        • FalsableReturnStatement
        • FalseOperand
        • ForbiddenCode
        • IfThisIsMismatch
        • ImmutableDependency
        • ImplementationRequirementViolation
        • ImplementedParamTypeMismatch
        • ImplementedReturnTypeMismatch
        • ImplicitToStringCast
        • ImpureByReferenceAssignment
        • ImpureFunctionCall
        • ImpureGlobalVariable
        • ImpureMethodCall
        • ImpurePropertyAssignment
        • ImpurePropertyFetch
        • ImpureStaticProperty
        • ImpureStaticVariable
        • ImpureVariable
        • InaccessibleClassConstant
        • InaccessibleMethod
        • InaccessibleProperty
        • IncompatibleTypeParameters
        • InheritorViolation
        • InterfaceInstantiation
        • InternalClass
        • InternalMethod
        • InternalProperty
        • InvalidArgument
        • InvalidArrayAccess
        • InvalidArrayAssignment
        • InvalidArrayOffset
        • InvalidAttribute
        • InvalidCast
        • InvalidCatch
        • InvalidClass
        • InvalidClassConstantType
        • InvalidClone
        • InvalidConstantAssignmentValue
        • InvalidDocblock
        • InvalidDocblockParamName
        • InvalidEnumBackingType
        • InvalidEnumCaseValue
        • InvalidEnumMethod
        • InvalidExtendClass
        • InvalidFalsableReturnType
        • InvalidFunctionCall
        • InvalidGlobal
        • InvalidInterfaceImplementation
        • InvalidIterator
        • InvalidLiteralArgument
        • InvalidMethodCall
        • InvalidNamedArgument
        • InvalidNullableReturnType
        • InvalidOperand
        • InvalidOverride
        • InvalidParamDefault
        • InvalidParent
        • InvalidPassByReference
        • InvalidPropertyAssignment
        • InvalidPropertyAssignmentValue
        • InvalidPropertyFetch
        • InvalidReturnStatement
        • InvalidReturnType
        • InvalidScalarArgument
        • InvalidScope
        • InvalidStaticInvocation
        • InvalidStringClass
        • InvalidTemplateParam
        • InvalidThrow
        • InvalidToString
        • InvalidTraversableImplementation
        • InvalidTypeImport
        • LessSpecificClassConstantType
        • LessSpecificImplementedReturnType
        • LessSpecificReturnStatement
        • LessSpecificReturnType
        • LiteralKeyUnshapedArray
        • LoopInvalidation
        • MethodSignatureMismatch
        • MethodSignatureMustOmitReturnType
        • MethodSignatureMustProvideReturnType
        • MismatchingDocblockParamType
        • MismatchingDocblockPropertyType
        • MismatchingDocblockReturnType
        • MissingAbstractPureAnnotation
        • MissingClassConstType
        • MissingClosureParamType
        • MissingClosureReturnType
        • MissingConstructor
        • MissingDependency
        • MissingDocblockType
        • MissingFile
        • MissingImmutableAnnotation
        • MissingInterfaceImmutableAnnotation
        • MissingOverrideAttribute
        • MissingParamType
        • MissingPropertyType
        • MissingPureAnnotation
        • MissingReturnType
        • MissingTemplateParam
        • MissingThrowsDocblock
        • MixedArgument
        • MixedArgumentTypeCoercion
        • MixedArrayAccess
        • MixedArrayAssignment
        • MixedArrayOffset
        • MixedArrayTypeCoercion
        • MixedAssignment
        • MixedClone
        • MixedFunctionCall
        • MixedMethodCall
        • MixedOperand
        • MixedPropertyAssignment
        • MixedPropertyFetch
        • MixedPropertyTypeCoercion
        • MixedReturnStatement
        • MixedReturnTypeCoercion
        • MixedStringOffsetAssignment
        • MoreSpecificImplementedParamType
        • MoreSpecificReturnType
        • MutableDependency
        • NamedArgumentNotAllowed
        • NoEnumProperties
        • NoInterfaceProperties
        • NonInvariantDocblockPropertyType
        • NonInvariantPropertyType
        • NonStaticSelfCall
        • NonVariableReferenceReturn
        • NoValue
        • NullableReturnStatement
        • NullArgument
        • NullArrayAccess
        • NullArrayOffset
        • NullFunctionCall
        • NullIterator
        • NullOperand
        • NullPropertyAssignment
        • NullPropertyFetch
        • NullReference
        • OverriddenFinalConstant
        • OverriddenFinalProperty
        • OverriddenInterfaceConstant
        • OverriddenMethodAccess
        • OverriddenPropertyAccess
        • ParadoxicalCondition
        • ParamNameMismatch
        • ParentNotFound
        • ParseError
        • PluginIssue
        • PossibleRawObjectIteration
        • PossiblyFalseArgument
        • PossiblyFalseIterator
        • PossiblyFalseOperand
        • PossiblyFalsePropertyAssignmentValue
        • PossiblyFalseReference
        • PossiblyInvalidArgument
        • PossiblyInvalidArrayAccess
        • PossiblyInvalidArrayAssignment
        • PossiblyInvalidArrayOffset
        • PossiblyInvalidCast
        • PossiblyInvalidClone
        • PossiblyInvalidDocblockTag
        • PossiblyInvalidFunctionCall
        • PossiblyInvalidIterator
        • PossiblyInvalidMethodCall
        • PossiblyInvalidOperand
        • PossiblyInvalidPropertyAssignment
        • PossiblyInvalidPropertyAssignmentValue
        • PossiblyInvalidPropertyFetch
        • PossiblyNullArgument
        • PossiblyNullArrayAccess
        • PossiblyNullArrayAssignment
        • PossiblyNullArrayOffset
        • PossiblyNullFunctionCall
        • PossiblyNullIterator
        • PossiblyNullOperand
        • PossiblyNullPropertyAssignment
        • PossiblyNullPropertyAssignmentValue
        • PossiblyNullPropertyFetch
        • PossiblyNullReference
        • PossiblyUndefinedArrayOffset
        • PossiblyUndefinedGlobalVariable
        • PossiblyUndefinedIntArrayOffset
        • PossiblyUndefinedMethod
        • PossiblyUndefinedStringArrayOffset
        • PossiblyUndefinedVariable
        • PossiblyUnusedMethod
        • PossiblyUnusedParam
        • PossiblyUnusedProperty
        • PossiblyUnusedReturnValue
        • PrivateFinalMethod
        • PropertyNotSetInConstructor
        • PropertyTypeCoercion
        • RawObjectIteration
        • RedundantCast
        • RedundantCastGivenDocblockType
        • RedundantCondition
        • RedundantConditionGivenDocblockType
        • RedundantFlag
        • RedundantFunctionCall
        • RedundantFunctionCallGivenDocblockType
        • RedundantIdentityWithTrue
        • RedundantPropertyInitializationCheck
        • ReferenceConstraintViolation
        • ReferenceReusedFromConfusingScope
        • ReservedWord
        • RiskyCast
        • RiskyTruthyFalsyComparison
        • StringIncrement
        • TaintedCallable
        • TaintedCookie
        • TaintedCustom
        • TaintedEval
        • TaintedExtract
        • TaintedFile
        • TaintedHeader
        • TaintedHtml
        • TaintedInclude
        • TaintedInput
        • TaintedLdap
        • TaintedLlmPrompt
        • TaintedNosql
        • TaintedShell
        • TaintedSleep
        • TaintedSql
        • TaintedSSRF
        • TaintedSystemSecret
        • TaintedTextWithQuotes
        • TaintedUnserialize
        • TaintedUserSecret
        • TaintedXpath
        • TooFewArguments
        • TooManyArguments
        • TooManyTemplateParams
        • Trace
        • TraitMethodSignatureMismatch
        • TypeDoesNotContainNull
        • TypeDoesNotContainType
        • UncaughtThrowInGlobalScope
        • UndefinedAttributeClass
        • UndefinedClass
        • UndefinedConstant
        • UndefinedDocblockClass
        • UndefinedFunction
        • UndefinedGlobalVariable
        • UndefinedInterface
        • UndefinedInterfaceMethod
        • UndefinedMagicMethod
        • UndefinedMagicPropertyAssignment
        • UndefinedMagicPropertyFetch
        • UndefinedMethod
        • UndefinedPropertyAssignment
        • UndefinedPropertyFetch
        • UndefinedThisPropertyAssignment
        • UndefinedThisPropertyFetch
        • UndefinedTrace
        • UndefinedTrait
        • UndefinedVariable
        • UnevaluatedCode
        • UnhandledMatchCondition
        • UnimplementedAbstractMethod
        • UnimplementedInterfaceMethod
        • UninitializedProperty
        • UnnecessaryVarAnnotation
        • UnrecognizedExpression
        • UnrecognizedStatement
        • UnresolvableConstant
        • UnresolvableInclude
        • UnsafeGenericInstantiation
        • UnsafeInstantiation
        • UnsupportedPropertyReferenceUsage
        • UnsupportedReferenceUsage
        • UnusedBaselineEntry
        • UnusedClass
        • UnusedClosureParam
        • UnusedConstructor
        • UnusedDocblockParam
        • UnusedForeachValue
        • UnusedFunctionCall
        • UnusedIssueHandlerSuppression
        • UnusedMethod
        • UnusedMethodCall
        • UnusedParam
        • UnusedProperty
        • UnusedPsalmSuppress
        • UnusedReturnValue
        • UnusedVariable
      • Checking non-PHP files
      • Error levels
    • Annotating code
      • Typing in Psalm
      • Supported Annotations
      • Template Annotations
      • Type Variables
      • Adding assertions
      • Assertion syntax
      • Type syntax
        • Array types
        • Atomic types
        • Callable types
        • Conditional types
        • Intersection types
        • Object types
        • Other types
        • Scalar types
        • Top types, bottom types
        • Union Types
        • Utility types
        • Value types
    • Manipulating code
      • Fixing code
      • Refactoring code
    • Contributing
      • Overview
      • How Psalm works
      • Philosophy
      • Things that make developing Psalm complicated
      • Altering callmaps
      • Adding a new issue type
    • Security analysis
      • Overview
      • Custom Taint Sources
      • Custom Taint Sinks
      • Avoiding false-positives
      • Avoiding false-negatives
      • Security analysis annotations
      • Taint Flow
    Docs source on GitHub
    

    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:

    Note: you can view detailed documentation and usage examples for all atomic types by clicking on each type in the following list.

    • Scalar types
      • bool
      • int
      • float
      • string
      • int-range<x, y>
      • int-mask<1, 2, 4>
      • int-mask-of<MyClass::CLASS_CONSTANT_*>
      • class-string and class-string<Foo>
      • trait-string
      • enum-string
      • callable-string
      • numeric-string
      • literal-string
      • literal-int
      • array-key
      • numeric
      • scalar
    • Object types
      • object
      • object{foo: string}
      • Exception, Foo\MyClass and Foo\MyClass<Bar>
      • Generator
    • Array types
      • array<int, string>
      • non-empty-array
      • string[]
      • list & non-empty-list
      • list<string>
      • array{foo: int, bar: string} and list{int, string}
      • callable-array
    • Callable types
    • Value types
      • null
      • true, false
      • 6, 7.0, "forty-two" and 'forty two'
      • Foo\Bar::MY_SCALAR_CONST
    • Utility types
      • (T is true ? string : bool)
      • key-of<T>
      • value-of<T>
      • properties-of<T>
      • class-string-map<T of Foo, T>
      • T[K]
      • Type aliases
      • Variable templates
    • Other types
      • iterable<TKey, TValue>
      • void
      • resource
      • closed-resource
    • Top and bottom types
      • mixed
      • never
    Previous Array types
    Next Callable types
    powered by MkDocs and Material for MkDocs