/** * Collects information about code coverage. * @return array */ private static function collectPhpDbg() { $positive = phpdbg_end_oplog(); $negative = phpdbg_get_executable(); foreach ($positive as $file => &$lines) { $lines = array_fill_keys(array_keys($lines), 1); } foreach ($negative as $file => &$lines) { $lines = array_fill_keys(array_keys($lines), -1); } return array($positive, $negative); }
/** * Stop collection of code coverage information. * * @return array */ public function stop() { static $fetchedLines = array(); $dbgData = phpdbg_end_oplog(); if ($fetchedLines == array()) { $sourceLines = phpdbg_get_executable(); } else { $newFiles = array_diff(get_included_files(), array_keys($fetchedLines)); if ($newFiles) { $sourceLines = phpdbg_get_executable(array('files' => $newFiles)); } else { $sourceLines = array(); } } foreach ($sourceLines as $file => $lines) { foreach ($lines as $lineNo => $numExecuted) { $sourceLines[$file][$lineNo] = self::LINE_NOT_EXECUTED; } } $fetchedLines = array_merge($fetchedLines, $sourceLines); return $this->detectExecutedLines($fetchedLines, $dbgData); }