<?php
declare(strict_types=1);

/**
 * Output escaping helpers (B3.4)
 * Use e() for HTML text nodes, e_attr() for attributes, e_url() for URLs.
 */
function e(?string $s): string {
  return htmlspecialchars((string)$s, ENT_QUOTES | ENT_SUBSTITUTE, 'UTF-8');
}
function e_attr(?string $s): string {
  return htmlspecialchars((string)$s, ENT_QUOTES | ENT_SUBSTITUTE, 'UTF-8');
}
function e_url(?string $s): string {
  $s = (string)$s;
  // Don't "validate" here; just escape. Validation belongs in handlers.
  return htmlspecialchars($s, ENT_QUOTES | ENT_SUBSTITUTE, 'UTF-8');
}
