Skip to content

Commit fe27297

Browse files
committed
Reworked ProcessedClassType, ProcessedTraitType
1 parent 034866b commit fe27297

File tree

13 files changed

+237
-217
lines changed

13 files changed

+237
-217
lines changed

src/Data/ProcessedClassType.php

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<?php declare(strict_types=1);
2+
/*
3+
* This file is part of phpunit/php-code-coverage.
4+
*
5+
* (c) Sebastian Bergmann <sebastian@phpunit.de>
6+
*
7+
* For the full copyright and license information, please view the LICENSE
8+
* file that was distributed with this source code.
9+
*/
10+
namespace SebastianBergmann\CodeCoverage\Data;
11+
12+
final class ProcessedClassType
13+
{
14+
public function __construct(
15+
public string $className,
16+
public string $namespace,
17+
/**
18+
* @var array<string, ProcessedMethodType>
19+
*/
20+
public array $methods,
21+
public int $startLine,
22+
public int $executableLines,
23+
public int $executedLines,
24+
public int $executableBranches,
25+
public int $executedBranches,
26+
public int $executablePaths,
27+
public int $executedPaths,
28+
public int $ccn,
29+
public float|int $coverage,
30+
public int|string $crap,
31+
public string $link,
32+
) {
33+
}
34+
}

src/Data/ProcessedTraitType.php

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<?php declare(strict_types=1);
2+
/*
3+
* This file is part of phpunit/php-code-coverage.
4+
*
5+
* (c) Sebastian Bergmann <sebastian@phpunit.de>
6+
*
7+
* For the full copyright and license information, please view the LICENSE
8+
* file that was distributed with this source code.
9+
*/
10+
namespace SebastianBergmann\CodeCoverage\Data;
11+
12+
final class ProcessedTraitType
13+
{
14+
public function __construct(
15+
public string $traitName,
16+
public string $namespace,
17+
/**
18+
* @var array<string, ProcessedMethodType>
19+
*/
20+
public array $methods,
21+
public int $startLine,
22+
public int $executableLines,
23+
public int $executedLines,
24+
public int $executableBranches,
25+
public int $executedBranches,
26+
public int $executablePaths,
27+
public int $executedPaths,
28+
public int $ccn,
29+
public float|int $coverage,
30+
public int|string $crap,
31+
public string $link,
32+
) {
33+
}
34+
}

src/Node/AbstractNode.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,14 @@
1515
use function str_replace;
1616
use function substr;
1717
use Countable;
18+
use SebastianBergmann\CodeCoverage\Data\ProcessedClassType;
1819
use SebastianBergmann\CodeCoverage\Data\ProcessedFunctionType;
20+
use SebastianBergmann\CodeCoverage\Data\ProcessedTraitType;
1921
use SebastianBergmann\CodeCoverage\StaticAnalysis\LinesOfCode;
2022
use SebastianBergmann\CodeCoverage\Util\Percentage;
2123

2224
/**
2325
* @internal This class is not covered by the backward compatibility promise for phpunit/php-code-coverage
24-
*
25-
* @phpstan-import-type ProcessedClassType from File
26-
* @phpstan-import-type ProcessedTraitType from File
2726
*/
2827
abstract class AbstractNode implements Countable
2928
{
@@ -186,7 +185,7 @@ public function cyclomaticComplexity(): int
186185
$ccn = 0;
187186

188187
foreach ($this->classesAndTraits() as $classLike) {
189-
$ccn += $classLike['ccn'];
188+
$ccn += $classLike->ccn;
190189
}
191190

192191
foreach ($this->functions() as $function) {

src/Node/Directory.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,14 @@
1414
use function count;
1515
use IteratorAggregate;
1616
use RecursiveIteratorIterator;
17+
use SebastianBergmann\CodeCoverage\Data\ProcessedClassType;
1718
use SebastianBergmann\CodeCoverage\Data\ProcessedFunctionType;
19+
use SebastianBergmann\CodeCoverage\Data\ProcessedTraitType;
1820
use SebastianBergmann\CodeCoverage\StaticAnalysis\LinesOfCode;
1921

2022
/**
2123
* @template-implements IteratorAggregate<int, AbstractNode>
2224
*
23-
* @phpstan-import-type ProcessedClassType from File
24-
* @phpstan-import-type ProcessedTraitType from File
25-
*
2625
* @internal This class is not covered by the backward compatibility promise for phpunit/php-code-coverage
2726
*/
2827
final class Directory extends AbstractNode implements IteratorAggregate

0 commit comments

Comments
 (0)