/** * @param AnalyzerFileResult $fileResult * * @return string */ private function renderUndeadTombstones(AnalyzerFileResult $fileResult) { $itemList = ''; foreach ($fileResult->getUndead() as $tombstone) { $invocation = $this->renderInvokers($tombstone); $this->undeadTemplate->setVar(array('path_to_root' => './', 'tombstone' => $this->linkTombstoneSource((string) $tombstone, $fileResult->getFile(), $tombstone->getLine()), 'line' => $tombstone->getLine(), 'method' => $tombstone->getMethod(), 'invocation' => $invocation)); $itemList .= $this->undeadTemplate->render(); } return $itemList; }
/** * @param AnalyzerFileResult $fileResult * * @return string */ private function formatSourceCode(AnalyzerFileResult $fileResult) { $deadLines = array(); $undeadLines = array(); foreach ($fileResult->getDead() as $tombstone) { $deadLines[] = $tombstone->getLine(); } foreach ($fileResult->getUndead() as $tombstone) { $undeadLines[] = $tombstone->getLine(); } $formattedCode = ''; $i = 0; $code = PhpFileFormatter::loadFile($fileResult->getFile()); $lineTemplate = '<tr class="%s"><td class="number"><div align="right"><a name="%d"></a><a href="#%d">%d</a></div></td><td class="codeLine">%s</td></tr>'; foreach ($code as $codeLine) { ++$i; $class = 'default'; if (in_array($i, $undeadLines)) { $class = 'danger icon-vampire'; } else { if (in_array($i, $deadLines)) { $class = 'success icon-cross'; } } $formattedCode .= sprintf($lineTemplate, $class, $i, $i, $i, $codeLine); } return $formattedCode; }