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 | ||
|---|---|---|
public
|
__construct(TrinaryLogic $result, list<string> $reasons)
|
# |
public
|
yes(): bool
|
# |
public
|
maybe(): bool
|
# |
public
|
no(): bool
|
# |
public
static
|
createYes(): self
|
# |
public
static
|
createNo(list<string> $reasons = []): self
|
# |
public
static
|
createMaybe(): self
|
# |
public
static
|
createFromBoolean(bool $value): self
|
# |
public
|
toAcceptsResult(): AcceptsResult
|
# |
public
|
and(self ...$others): self
|
# |
public
|
or(self ...$others): self
|
# |
public
|
decorateReasons(callable(string): string $cb): self
|
# |
public
static
|
extremeIdentity(self ...$operands): self
|
# |
public
static
|
maxMin(self ...$operands): self
|
# |
public
|
negate(): self
|
# |
public
|
describe(): string
|
# |