capture-headers.php

<?php

namespace Lia\Http;

global $liaison_debug_headers;
$liaison_debug_headers = [];


if (!function_exists('Lia\\Http\\header')){
    /**
     * The Response class is in the Lia\Http namespace and calls `header()`. This is overrides that to capture headers for tests.
     */
    function header(string $header, bool $replace = true, int $response_code = 0): void {
        global $liaison_debug_headers;
        $liaison_debug_headers[] = ['header'=>$header, 'replace'=>$replace, 'response_code'=>$response_code];
    }
}