<?php
declare(strict_types=1);
// Pure dispatcher proof: no application boot, controller construction, PDO or HTTP.
$root = '/workspace/zhct/zhctproject/store/';
define('APP_PATH', $root . 'application/');
define('ROOT_PATH', $root);
define('TP_ENV', 'local');
define('BUSINESS', '');
require $root . 'thinkphp/base.php';
\think\Config::set('route_check_cache', false);
\think\Config::set('url_convert', false);
\think\App::$debug = true;
require APP_PATH . 'route.php';
$candidates = json_decode(file_get_contents(__DIR__ . '/static-candidates.json'), true);
$results = [];
foreach ($candidates['candidates'] as $candidate) {
    $request = \think\Request::create($candidate['path'], 'POST');
    \think\Request::instance($request);
    $dispatch = \think\Route::check($request, ltrim($candidate['path'], '/'), '/', false);
    $results[] = ['path' => $candidate['path'], 'method' => 'POST', 'dispatch' => $dispatch,
        'route_info' => $request->routeInfo()];
}
$report = ['db_connections' => 0, 'http' => 0, 'results' => $results];
file_put_contents(__DIR__ . '/route-dispatch.json', json_encode($report, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE) . "\n");
echo json_encode($report, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE), "\n";
