function ParsingFileAnalyser::findLinesIgnoredByLineBasedAnnotations
1 call to ParsingFileAnalyser::findLinesIgnoredByLineBasedAnnotations()
- ParsingFileAnalyser::analyse in vendor/
phpunit/ php-code-coverage/ src/ StaticAnalysis/ ParsingFileAnalyser.php
File
-
vendor/
phpunit/ php-code-coverage/ src/ StaticAnalysis/ ParsingFileAnalyser.php, line 204
Class
- ParsingFileAnalyser
- @internal This class is not covered by the backward compatibility promise for phpunit/php-code-coverage
Namespace
SebastianBergmann\CodeCoverage\StaticAnalysisCode
private function findLinesIgnoredByLineBasedAnnotations(string $filename, string $source, bool $useAnnotationsForIgnoringCode) : void {
if (!$useAnnotationsForIgnoringCode) {
return;
}
$start = false;
foreach (token_get_all($source) as $token) {
if (!is_array($token) || !(T_COMMENT === $token[0] || T_DOC_COMMENT === $token[0])) {
continue;
}
$comment = trim($token[1]);
if ($comment === '// @codeCoverageIgnore' || $comment === '//@codeCoverageIgnore') {
$this->ignoredLines[$filename][] = $token[2];
continue;
}
if ($comment === '// @codeCoverageIgnoreStart' || $comment === '//@codeCoverageIgnoreStart') {
$start = $token[2];
continue;
}
if ($comment === '// @codeCoverageIgnoreEnd' || $comment === '//@codeCoverageIgnoreEnd') {
if (false === $start) {
$start = $token[2];
}
$this->ignoredLines[$filename] = array_merge($this->ignoredLines[$filename], range($start, $token[2]));
}
}
}