]+)~', $s, $matches); foreach ($matches[1] as $val) { if ($val{0} == "/") { array_pop($return); } elseif (substr($val, -1) != "/") { $return[] = $val; } } return $return; } if (!extension_loaded("xdebug")) { echo "

Xdebug has to be enabled.

\n"; } if ($_GET["start"]) { unset($_SESSION["coverage"]); xdebug_start_code_coverage(XDEBUG_CC_UNUSED | XDEBUG_CC_DEAD_CODE); $_SESSION["coverage"] = array(); include "./adminer/index.php"; header("Location: ."); exit; } if (preg_match('~^(include/)?[-_.a-z0-9]+$~i', $_GET["filename"])) { // highlight single file $filename = "adminer/$_GET[filename]"; $cov = $_SESSION["coverage"][realpath($filename)]; $file = explode("
", highlight_file($filename, true)); unset($prev_color); $s = ""; for ($l=0; $l <= count($file); $l++) { $line = $file[$l]; $color = "#C0FFC0"; // tested switch ($cov[$l+1]) { case -1: $color = "#FFC0C0"; break; // untested case -2: $color = "Silver"; break; // dead code case null: $color = ""; break; // not executable } if (!isset($prev_color)) { $prev_color = $color; } if ($prev_color != $color || !isset($line)) { echo "" . $s; $open_tags = xhtml_open_tags($s); foreach (array_reverse($open_tags) as $tag) { echo ""; } echo "\n"; $s = ($open_tags ? "<" . implode("><", $open_tags) . ">" : ""); $prev_color = $color; } $s .= "$line
\n"; } } else { // display list of files echo "\n"; foreach (array_merge(glob("adminer/*.php"), glob("adminer/include/*.php")) as $filename) { $cov = $_SESSION["coverage"][realpath($filename)]; $filename = substr($filename, 8); $ratio = 0; if (isset($cov)) { $values = array_count_values($cov); $ratio = round(100 - 100 * $values[-1] / count($cov)); } echo "\n"; } echo "
$ratio%$filename
\n"; echo "

Start new coverage (requires Xdebug)

\n"; }