isMatchedBy($this); } return $other instanceof self || $other instanceof ScalarConcreteType || $other instanceof MixedType; } public function inferGenericsFrom(Type $other, Generics $generics): Generics { return $generics; } public function canCast(mixed $value): bool { return is_bool($value) || $value === '1' || $value === '0' || $value === 1 || $value === 0 || $value === 'true' || $value === 'false'; } public function cast(mixed $value): bool { assert($this->canCast($value)); if ($value === 'false') { return false; } return (bool)$value; } public function errorMessage(): ErrorMessage { return MessageBuilder::newError('Value {source_value} is not a valid boolean.') ->withCode('invalid_boolean') ->build(); } public function nativeType(): NativeBooleanType { return $this; } public function toString(): string { return 'bool'; } }