value; } public function compiledAccept(ComplianceNode $node): ComplianceNode { return $node->equals(Node::value($this->value)); } public function matches(Type $other): bool { return $other->accepts($this->value); } public function inferGenericsFrom(Type $other, Generics $generics): Generics { return $generics; } public function canCast(mixed $value): bool { if ($value === $this->value) { return true; } if ($this->value === true) { return $value === '1' || $value === 1 || $value === 'true'; } return $value === '0' || $value === 0 || $value === 'false'; } public function cast(mixed $value): bool { assert($this->canCast($value)); return $this->value; } public function errorMessage(): ErrorMessage { return MessageBuilder::newError('Value {source_value} does not match boolean value {expected_value}.') ->withCode('invalid_boolean_value') ->withParameter('expected_value', $this->toString()) ->build(); } public function value(): bool { return $this->value; } public function nativeType(): NativeBooleanType { return NativeBooleanType::get(); } public function toString(): string { return $this->value ? 'true' : 'false'; } }