|
44 | 44 | */ |
45 | 45 |
|
46 | 46 | require_once 'PHP/CodeCoverage.php'; |
| 47 | +require_once 'PHP/Token/Stream.php'; |
47 | 48 |
|
48 | 49 | /** |
49 | 50 | * Generates a Clover XML logfile from an PHP_CodeCoverage object. |
@@ -116,9 +117,9 @@ public function process(PHP_CodeCoverage $coverage, $target = NULL, $name = NULL |
116 | 117 | $file = $document->createElement('file'); |
117 | 118 | $file->setAttribute('name', $filename); |
118 | 119 |
|
119 | | - $classesInFile = PHP_CodeCoverage_Util::getClassesInFile( |
120 | | - $filename |
121 | | - ); |
| 120 | + $tokens = new PHP_Token_Stream($filename); |
| 121 | + $classesInFile = $tokens->getClasses(); |
| 122 | + $linesOfCode = $tokens->getLinesOfCode(); |
122 | 123 |
|
123 | 124 | $ignoredLines = PHP_CodeCoverage_Util::getLinesToBeIgnored( |
124 | 125 | $filename |
@@ -201,7 +202,7 @@ public function process(PHP_CodeCoverage $coverage, $target = NULL, $name = NULL |
201 | 202 | } |
202 | 203 |
|
203 | 204 | $package = PHP_CodeCoverage_Util::getPackageInformation( |
204 | | - $className, $_class['docComment'] |
| 205 | + $className, $_class['docblock'] |
205 | 206 | ); |
206 | 207 |
|
207 | 208 | if (!empty($package['namespace'])) { |
@@ -337,11 +338,10 @@ public function process(PHP_CodeCoverage $coverage, $target = NULL, $name = NULL |
337 | 338 | $file->appendChild($line); |
338 | 339 | } |
339 | 340 |
|
340 | | - $count = PHP_CodeCoverage_Util::countLines($filename); |
341 | 341 | $metrics = $document->createElement('metrics'); |
342 | 342 |
|
343 | | - $metrics->setAttribute('loc', $count['loc']); |
344 | | - $metrics->setAttribute('ncloc', $count['ncloc']); |
| 343 | + $metrics->setAttribute('loc', $linesOfCode['loc']); |
| 344 | + $metrics->setAttribute('ncloc', $linesOfCode['ncloc']); |
345 | 345 | $metrics->setAttribute('classes', $fileStatistics['classes']); |
346 | 346 | $metrics->setAttribute('methods', $fileStatistics['methods']); |
347 | 347 |
|
@@ -396,8 +396,8 @@ public function process(PHP_CodeCoverage $coverage, $target = NULL, $name = NULL |
396 | 396 | $packages[$namespace]->appendChild($file); |
397 | 397 | } |
398 | 398 |
|
399 | | - $projectStatistics['loc'] += $count['loc']; |
400 | | - $projectStatistics['ncloc'] += $count['ncloc']; |
| 399 | + $projectStatistics['loc'] += $linesOfCode['loc']; |
| 400 | + $projectStatistics['ncloc'] += $linesOfCode['ncloc']; |
401 | 401 | $projectStatistics['classes'] += $fileStatistics['classes']; |
402 | 402 | $projectStatistics['methods'] += $fileStatistics['methods']; |
403 | 403 | $projectStatistics['coveredMethods'] += $fileStatistics['coveredMethods']; |
|
0 commit comments