Class PHPStan\Type\IsSuperTypeOfResult

final

Result of a Type::isSuperTypeOf() check — whether one type is a supertype of another. Wraps a TrinaryLogic result together with human-readable reasons explaining the relationship. This is the primary mechanism for comparing types in PHPStan's type system. isSuperTypeOf() answers: "Can all values of type B also be values of type A?" For example:

  • (new StringType())->isSuperTypeOf(new ConstantStringType('hello')) → Yes
  • (new IntegerType())->isSuperTypeOf(new StringType()) → No
  • (new StringType())->isSuperTypeOf(new MixedType()) → Maybe This is distinct from accepts() which also considers rule levels and PHPDoc context. Use isSuperTypeOf() for type-theoretic comparisons and accepts() for assignability checks. Can be converted to AcceptsResult via toAcceptsResult().
Methods