Interface PHPStan\Type\Type

Represents a PHPStan type in the type system.

This is the central interface of PHPStan's type system. Every type that PHPStan can reason about implements this interface — from simple scalars like StringType to complex generics like GenericObjectType.

Each Type knows what it accepts, what is a supertype of it, what properties/methods/constants it has, what operations it supports, and how to describe itself for error messages.

Important: Never use instanceof to check types. For example, $type instanceof StringType will miss union types, intersection types with accessory types, and other composite forms. Always use the is*() methods or isSuperTypeOf() instead:

// Wrong:
if ($type instanceof StringType) { ... }

// Correct:
if ($type->isString()->yes()) { ... }
Located at src/Type/Type.php
Methods