> $request */ public static function getPositiveIntParam(WP_REST_Request $request, string $key = 'id'): ?int { $raw = $request->get_param($key); if ($raw === null || $raw === '' || !is_scalar($raw)) { return null; } $id = (int) $raw; return $id > 0 ? $id : null; } }