alias( static fn (mixed $checked, mixed $current = true, bool $echo = true): string => self::formAttribute('checked', $checked, $current, $echo) ); Monkey\Functions\when('selected')->alias( static fn (mixed $selected, mixed $current = true, bool $echo = true): string => self::formAttribute('selected', $selected, $current, $echo) ); } /** Mirrors WordPress's `__checked_selected_helper()`, echo included. */ private static function formAttribute(string $type, mixed $helper, mixed $current, bool $echo): string { // WordPress compares loosely, and templates rely on that: `checked($a, $b)` // is routinely called with an int against a numeric string. $result = $helper == $current ? " {$type}='{$type}'" : ''; // phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison if ($echo) { echo $result; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- fixed literal. } return $result; } protected function tearDown(): void { Monkey\tearDown(); parent::tearDown(); } /** * Stub `wpautop()` with a minimal blank-line-to-paragraph transform — enough * to assert that unmarked-up text reaches the page as real paragraphs. */ protected function stubAutop(): void { Monkey\Functions\when('wpautop')->alias(static function (string $text): string { $text = trim($text); return '' === $text ? '' : '
' . implode('
', (array) preg_split('/\n\s*\n/', $text)) . '
'; }); } }