Skip to content

Commit

Permalink
Remove some ancient workarounds for very old Xdebug versions
Browse files Browse the repository at this point in the history
  • Loading branch information
dvdoug authored and sebastianbergmann committed May 13, 2020
1 parent 1894727 commit 0eb29be
Showing 1 changed file with 0 additions and 42 deletions.
42 changes: 0 additions & 42 deletions src/Driver/Xdebug.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,6 @@
*/
final class Xdebug implements Driver
{
/**
* @var array
*/
private $cacheNumLines = [];

/**
* @var Filter
*/
Expand Down Expand Up @@ -68,43 +63,6 @@ public function stop(): array

\xdebug_stop_code_coverage();

return $this->cleanup($data);
}

private function cleanup(array $data): array
{
foreach (\array_keys($data) as $file) {
unset($data[$file][0]);

if (!$this->filter->isFile($file)) {
continue;
}

$numLines = $this->getNumberOfLinesInFile($file);

foreach (\array_keys($data[$file]) as $line) {
if ($line > $numLines) {
unset($data[$file][$line]);
}
}
}

return $data;
}

private function getNumberOfLinesInFile(string $fileName): int
{
if (!isset($this->cacheNumLines[$fileName])) {
$buffer = \file_get_contents($fileName);
$lines = \substr_count($buffer, "\n");

if (\substr($buffer, -1) !== "\n") {
$lines++;
}

$this->cacheNumLines[$fileName] = $lines;
}

return $this->cacheNumLines[$fileName];
}
}

0 comments on commit 0eb29be

Please sign in to comment.