<?php

declare(strict_types=1);

namespace Packetery\Tracy;

/**
 * @var string $source
 * @var callable $dump
 */

if (!Helpers::isCli()) {
	return;
}
?>
<section class="tracy-section">
	<h2 class="tracy-section-label"><a href="#" data-tracy-ref="^+" class="tracy-toggle tracy-collapsed">CLI request</a></h2>

	<div class="tracy-section-panel tracy-collapsed">
		<h3>Process ID <?= Helpers::escapeHtml(getmypid()) ?></h3>
		<pre>php<?= Helpers::escapeHtml(explode('):', $source, 2)[1]) ?></pre>

		<h3>Arguments</h3>
		<div class="tracy-pane">
			<table>
<?php foreach ($_SERVER['argv'] as $k => $v): ?>
				<tr><th><?= Helpers::escapeHtml($k) ?></th><td><?= $dump($v, $k) ?></td></tr>
<?php endforeach ?>
			</table>
		</div>
	</div>
</section>
