Files
ohmj2/api/coverage-prepend.php
T

26 lines
837 B
PHP

<?php
// Dev-only: prepend file that enables Xdebug code coverage on the PHP
// built-in server. Loaded via -d auto_prepend_file=... during coverage runs.
// Not shipped in the deploy archive (see deploy/deploy.sh).
if (!function_exists('xdebug_start_code_coverage')) {
return;
}
xdebug_set_filter(XDEBUG_FILTER_CODE_COVERAGE, XDEBUG_PATH_INCLUDE, [
realpath(__DIR__ . '/index.php'),
realpath(__DIR__ . '/router.php'),
realpath(__DIR__ . '/lib'),
]);
xdebug_start_code_coverage(XDEBUG_CC_UNUSED | XDEBUG_CC_DEAD_CODE);
register_shutdown_function(function () {
$cov = xdebug_get_code_coverage();
$dir = sys_get_temp_dir() . '/ohmj_cov';
if (!is_dir($dir)) {
@mkdir($dir, 0777, true);
}
@file_put_contents($dir . '/cov_' . getmypid() . '_' . uniqid('', true) . '.ser', serialize($cov));
});