<?php
// Execute only the source's date formatter/assignment; no application, DB or printer.
$path = __DIR__ . '/../../../zhctproject/store/application/p/logic/MealOrder.php';
$source = file_get_contents($path);
if (!preg_match('/private function formatReceiptTime\(string \$time\): string\s*\{.*?\n    \}/s', $source, $method)) {
    throw new RuntimeException('Date formatter source not found');
}
if (!preg_match('/\$bindTime = ([^;]+);/', $source, $assignment)) {
    throw new RuntimeException('Receipt date assignment not found');
}
eval('class ReceiptDateProbe {' . $method[0] . ' public function run(array $order) { return ' . $assignment[1] . '; }}');
$probe = new ReceiptDateProbe();
$fixture = ['bind_time' => '2026-09-12 11:05:59', 'meal_date' => '2026-09-14', 'take_time_start' => '11:30', 'take_time_end' => '19:30'];
$actual = $probe->run($fixture);
$expected = $fixture['meal_date'] . ' ' . $fixture['take_time_start'] . ' - ' . $fixture['take_time_end'];
if ($actual !== '2026-09-12 11:05:59' || $actual === $expected) {
    throw new RuntimeException('Reported mismatch no longer reproduced; inspect updated source');
}
echo "PASS: source reproduces receipt=$actual; expected=$expected\n";
$start = strpos($source, 'public function orderPrint(');
$end = strpos($source, '$order = $order->toArray();', $start);
$query = substr($source, $start, $end - $start);
foreach (['meal_date', 'take_time_start', 'take_time_end'] as $field) {
    if (strpos($query, "'" . $field . "'") !== false) {
        throw new RuntimeException('Query changed; reassess field projection');
    }
    echo "PASS: current print query omits $field\n";
}
echo "4 checks passed. Diagnostic reproduction only; no fix or printer test.\n";
