我在脚本的开头有以下内容:
if ($jsonFile = $_REQUEST['saveCoverageJson']??'')
{
xdebug_start_code_coverage();
register_shutdown_function(function() use ($jsonFile)
{
// wrapped to make pretty sure it's the very last thing executed
register_shutdown_function(function() use ($jsonFile)
{
xdebug_stop_code_coverage();
$dir = __DIR__.'/../misc/coverage-reports';
$coverageData = xdebug_get_code_coverage();
var_dump($coverageData);
file_put_contents(
$dir."/$jsonFile.json",
json_encode($coverageData, JSON_PRETTY_PRINT)
);
});
});
}
但是xdebug_get_code_coverage()返回一个空数组。出什么事了?我将xdebug.mode
设置为coverage
。谢谢
1条答案
按热度按时间bkkx9g8r1#
因为我叫了
xdebug_stop_code_coverage()
根据文档,它会破坏收集的信息!