true, "data" => $data], $status); } function json_error(string $code, string $message, int $status = 400): never { qdb_test_abort(["ok" => false, "error" => ["code" => $code, "message" => $message]], $status); } function read_json_body(): array { if (isset($GLOBALS['__TEST_JSON_BODY'])) { $data = json_decode($GLOBALS['__TEST_JSON_BODY'], true); if (!is_array($data)) { json_error('INVALID_BODY', 'Request body must be valid JSON', 400); } return $data; } $raw = file_get_contents('php://input'); $data = json_decode($raw, true); if (!is_array($data)) { json_error('INVALID_BODY', 'Request body must be valid JSON', 400); } return $data; }