????1. ??????????????
?????????????????к?????Σ??????и??????????/??????????????????????????????????????????????????????????????????????в??????????????????????????????????????????????????д??????????????????????Щ??????????缸?????????????????????????????????????????????????????PHP??????????PHPUnit??Spike PHPCoverage??????????xdebug???????????????????????У????????????????????????????????????????PHP????????????????????????
????2. ?????
???????????????????????????????????????????????й?????????????????????????????????£???????????????????????????????????????????й??????????飬?????Щ?????????????????????????????????е????????????????????????????????????????????????????????????????????????д?????д?????????????????Щ???????????????????2?????????????????в?????Щ??????????????????????????????????
?????????????????xdebug??????????????????????????????????£?
????xdebug_start_code_coverage(); //???????????и??????
????xdebug_get_code_coverage(); //???????????????????????????к?
????xdebug_stop_code_coverage(); //??????????и??????
????xdebug?????????????????и?????????????????????????????и???????????е???????????У????????????????????????????磬??β???????????A.php??????10?У????????ж?A.php?????????????A.php??9?к??10?????????????д??????????????10?б?????12?У???xdebug???и?????????????к?……??????????????????????????????????????????ú??????????????????????????????????У??????д???????????????????????????xdebug???????????????????
?????????????????????????????
??????1?????????β???????????????к????б???????????????ж??????????????????????????????
??????2???????????????????????????棬????????????????????
??????3??????????????????£?

???????в??????????????????????Щ?????????
????3. ????????????????
??????1?????
????xdebug??????????и???????????????????????????????????????????????????????????????Щ????????У???????????????ж??????????
??????????????????????????????????????к??????????飬??????????????????????????????????C++????Java?У???????????????????????????????????PHP???????????????????????????PHP4.3?????PHP Zend Engine????????tokenizer???????????????????????????????????????PHP?ж??庯??????????????????????????????PHP????е???????????
????tokenizer??????????????
????array token_get_all (string $source)
?????ú??????????????????php?????????token???????顣
????string token_name (int $token)
???????????????token????????????????????C?????е?strerror??????????tokenizer??????????php???????????????????????????????????????????????????????????????д???????a????????????ó????????????ο???PHPFunctionParser
???????????????????????????????????е?????б?????????????????Щ??·?????????????????????????xdebug?????????У?????????к???????????????????????????????ε??????????к?????????????????????????????1000?У????????1000???ж??Ч???????????????????????xdebug????function trace???????????????????е???????ù?????????????????????????????????????????????????????ε??????????????Reflection?????????????????????????????????????????ж??塣???????????function trace????????ù?????????????????У?????????????????????е???????????????????????“????::??????”??????????????reflection???????????????????????????ɡ??????????????????????????????
??????2?????
????????????????????????????????PHP???????á?xdebug??????????????????xdebug_start_code_coverage??xdebug_stop_code_coverage????????????????????????????????????????????????????????????????xdebug_stop_code_coverage???register_shutdown_function????php??????????????????γ???????C?????atexit???????????????????????У???????????????require?????????ɡ???????PHP?????CodeIgniter??????????????????????index.php???????????????????????????????????????е??????????????????????е?PHP?????????????index.php???????????????????
??????????????????????????index.php?????м???????仰??
????<?php require_once "/file/path/to/phpcoverage.php"; ?>
??????phpcoverage.php?????????????????£?
<?php
……
function xdebugPhpcoverageBeforeShutdown(){
……
$lineCovData = xdebug_get_code_coverage();
xdebug_stop_code_coverage();
……
xdebug_stop_trace();
……
}
register_shutdown_function(‘xdebugPhpcoverageBeforeShutdown’);
……
xdebug_start_trace(……);
xdebug_start_code_coverage();
????//???????????????????????????????