Skip to content

Commit 73fccca

Browse files
Merge branch '9.2'
2 parents e4dd4c1 + 2016ff1 commit 73fccca

File tree

3 files changed

+20
-16
lines changed

3 files changed

+20
-16
lines changed

src/CodeCoverage.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -398,10 +398,12 @@ private function applyExecutableLinesFilter(RawCodeCoverageData $data): void
398398
}
399399

400400
$linesToBranchMap = $this->analyser()->executableLinesIn($filename);
401+
401402
$data->keepLineCoverageDataOnlyForLines(
402403
$filename,
403404
array_keys($linesToBranchMap)
404405
);
406+
405407
$data->markExecutableLineByBranch(
406408
$filename,
407409
$linesToBranchMap

src/StaticAnalysis/ExecutableLinesFindingVisitor.php

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,7 @@ public function enterNode(Node $node): void
6969
}
7070

7171
if ($node instanceof Node\Scalar\String_ ||
72-
$node instanceof Node\Scalar\EncapsedStringPart
73-
) {
72+
$node instanceof Node\Scalar\EncapsedStringPart) {
7473
$startLine = $node->getStartLine() + 1;
7574
$endLine = $node->getEndLine() - 1;
7675

@@ -102,17 +101,15 @@ public function enterNode(Node $node): void
102101
$node instanceof Node\Identifier ||
103102
$node instanceof Node\Name ||
104103
$node instanceof Node\Param ||
105-
$node instanceof Node\Scalar
106-
) {
104+
$node instanceof Node\Scalar) {
107105
return;
108106
}
109107

110108
if ($node instanceof Node\Stmt\Function_ ||
111109
$node instanceof Node\Stmt\Class_ ||
112110
$node instanceof Node\Stmt\ClassMethod ||
113111
$node instanceof Node\Expr\Closure ||
114-
$node instanceof Node\Stmt\Trait_
115-
) {
112+
$node instanceof Node\Stmt\Trait_) {
116113
$isConcreteClassLike = $node instanceof Node\Stmt\Class_ || $node instanceof Node\Stmt\Trait_;
117114

118115
if (null !== $node->stmts) {
@@ -163,6 +160,7 @@ public function enterNode(Node $node): void
163160
$node->getStartLine() + 1,
164161
$node->expr->getStartLine()
165162
);
163+
166164
$endLine = $node->expr->getEndLine();
167165

168166
if ($endLine < $startLine) {
@@ -176,8 +174,7 @@ public function enterNode(Node $node): void
176174

177175
if ($node instanceof Node\Expr\Ternary) {
178176
if (null !== $node->if &&
179-
$node->getStartLine() !== $node->if->getEndLine()
180-
) {
177+
$node->getStartLine() !== $node->if->getEndLine()) {
181178
$this->setLineBranch($node->if->getStartLine(), $node->if->getEndLine(), ++$this->nextBranch);
182179
}
183180

@@ -198,8 +195,7 @@ public function enterNode(Node $node): void
198195

199196
if ($node instanceof Node\Stmt\If_ ||
200197
$node instanceof Node\Stmt\ElseIf_ ||
201-
$node instanceof Node\Stmt\Case_
202-
) {
198+
$node instanceof Node\Stmt\Case_) {
203199
if (null === $node->cond) {
204200
return;
205201
}
@@ -219,26 +215,35 @@ public function enterNode(Node $node): void
219215

220216
if ([] !== $node->init) {
221217
$startLine = $node->init[0]->getStartLine();
218+
222219
end($node->init);
220+
223221
$endLine = current($node->init)->getEndLine();
222+
224223
reset($node->init);
225224
}
226225

227226
if ([] !== $node->cond) {
228227
if (null === $startLine) {
229228
$startLine = $node->cond[0]->getStartLine();
230229
}
230+
231231
end($node->cond);
232+
232233
$endLine = current($node->cond)->getEndLine();
234+
233235
reset($node->cond);
234236
}
235237

236238
if ([] !== $node->loop) {
237239
if (null === $startLine) {
238240
$startLine = $node->loop[0]->getStartLine();
239241
}
242+
240243
end($node->loop);
244+
241245
$endLine = current($node->loop)->getEndLine();
246+
242247
reset($node->loop);
243248
}
244249

@@ -266,8 +271,7 @@ public function enterNode(Node $node): void
266271
}
267272

268273
if ($node instanceof Node\Stmt\While_ ||
269-
$node instanceof Node\Stmt\Do_
270-
) {
274+
$node instanceof Node\Stmt\Do_) {
271275
$this->setLineBranch(
272276
$node->cond->getStartLine(),
273277
$node->cond->getEndLine(),
@@ -322,8 +326,7 @@ public function afterTraverse(array $nodes): void
322326
(
323327
isset($this->commentsToCheckForUnset[$lineNumber]) &&
324328
1 === preg_match(sprintf('/^\s*%s\s*$/', preg_quote($this->commentsToCheckForUnset[$lineNumber], '/')), $line)
325-
)
326-
) {
329+
)) {
327330
unset($this->executableLinesGroupedByBranch[$lineNumber]);
328331
}
329332
}

src/StaticAnalysis/ParsingFileAnalyser.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -196,8 +196,7 @@ private function findLinesIgnoredByLineBasedAnnotations(string $filename, string
196196

197197
foreach (token_get_all($source) as $token) {
198198
if (!is_array($token) ||
199-
!(T_COMMENT === $token[0] || T_DOC_COMMENT === $token[0])
200-
) {
199+
!(T_COMMENT === $token[0] || T_DOC_COMMENT === $token[0])) {
201200
continue;
202201
}
203202

0 commit comments

Comments
 (0)