Skip to content

Commit c345268

Browse files
Do not pass $cacheTokens flag to Node objects
1 parent 10e993d commit c345268

File tree

4 files changed

+8
-28
lines changed

4 files changed

+8
-28
lines changed

src/CodeCoverage.php

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -327,14 +327,6 @@ public function disableTokenCaching(): void
327327
{
328328
}
329329

330-
/**
331-
* @todo remove
332-
*/
333-
public function cachesTokens(): bool
334-
{
335-
return false;
336-
}
337-
338330
public function enableCheckForUnintentionallyCoveredCode(): void
339331
{
340332
$this->checkForUnintentionallyCoveredCode = true;

src/Node/Builder.php

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,14 +40,13 @@ public function build(CodeCoverage $coverage): Directory
4040
$this->addItems(
4141
$root,
4242
$this->buildDirectoryStructure($data),
43-
$coverage->getTests(),
44-
$coverage->cachesTokens()
43+
$coverage->getTests()
4544
);
4645

4746
return $root;
4847
}
4948

50-
private function addItems(Directory $root, array $items, array $tests, bool $cacheTokens): void
49+
private function addItems(Directory $root, array $items, array $tests): void
5150
{
5251
foreach ($items as $key => $value) {
5352
$key = (string) $key;
@@ -56,11 +55,11 @@ private function addItems(Directory $root, array $items, array $tests, bool $cac
5655
$key = substr($key, 0, -2);
5756

5857
if (file_exists($root->pathAsString() . DIRECTORY_SEPARATOR . $key)) {
59-
$root->addFile($key, $value['lineCoverage'], $value['functionCoverage'], $tests, $cacheTokens);
58+
$root->addFile($key, $value['lineCoverage'], $value['functionCoverage'], $tests);
6059
}
6160
} else {
6261
$child = $root->addDirectory($key);
63-
$this->addItems($child, $value, $tests, $cacheTokens);
62+
$this->addItems($child, $value, $tests);
6463
}
6564
}
6665
}

src/Node/Directory.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,9 +160,9 @@ public function addDirectory(string $name): self
160160
return $directory;
161161
}
162162

163-
public function addFile(string $name, array $lineCoverageData, array $functionCoverageData, array $testData, bool $cacheTokens): File
163+
public function addFile(string $name, array $lineCoverageData, array $functionCoverageData, array $testData): File
164164
{
165-
$file = new File($name, $this, $lineCoverageData, $functionCoverageData, $testData, $cacheTokens);
165+
$file = new File($name, $this, $lineCoverageData, $functionCoverageData, $testData);
166166

167167
$this->children[] = $file;
168168
$this->files[] = &$this->children[count($this->children) - 1];

src/Node/File.php

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
use function strpos;
1717
use OutOfBoundsException;
1818
use PHP_Token_Stream;
19-
use PHP_Token_Stream_CachingFactory;
2019

2120
/**
2221
* @internal This class is not covered by the backward compatibility promise for phpunit/php-code-coverage
@@ -123,24 +122,18 @@ final class File extends AbstractNode
123122
*/
124123
private $numTestedFunctions;
125124

126-
/**
127-
* @var bool
128-
*/
129-
private $cacheTokens;
130-
131125
/**
132126
* @var array
133127
*/
134128
private $codeUnitsByLine = [];
135129

136-
public function __construct(string $name, AbstractNode $parent, array $lineCoverageData, array $functionCoverageData, array $testData, bool $cacheTokens)
130+
public function __construct(string $name, AbstractNode $parent, array $lineCoverageData, array $functionCoverageData, array $testData)
137131
{
138132
parent::__construct($name, $parent);
139133

140134
$this->lineCoverageData = $lineCoverageData;
141135
$this->functionCoverageData = $functionCoverageData;
142136
$this->testData = $testData;
143-
$this->cacheTokens = $cacheTokens;
144137

145138
$this->calculateStatistics();
146139
}
@@ -338,11 +331,7 @@ public function numberOfTestedFunctions(): int
338331

339332
private function calculateStatistics(): void
340333
{
341-
if ($this->cacheTokens) {
342-
$tokens = PHP_Token_Stream_CachingFactory::get($this->pathAsString());
343-
} else {
344-
$tokens = new PHP_Token_Stream($this->pathAsString());
345-
}
334+
$tokens = new PHP_Token_Stream($this->pathAsString());
346335

347336
$this->linesOfCode = $tokens->getLinesOfCode();
348337

0 commit comments

Comments
 (0)