Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions src/Data/ProcessedClassType.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?php declare(strict_types=1);
/*
* This file is part of phpunit/php-code-coverage.
*
* (c) Sebastian Bergmann <sebastian@phpunit.de>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace SebastianBergmann\CodeCoverage\Data;

/**
* @internal This class is not covered by the backward compatibility promise for phpunit/php-code-coverage
*/
final class ProcessedClassType
{
public function __construct(
public readonly string $className,
public readonly string $namespace,
/**
* @var array<string, ProcessedMethodType>
*/
public array $methods,
public readonly int $startLine,
public int $executableLines,
public int $executedLines,
public int $executableBranches,
public int $executedBranches,
public int $executablePaths,
public int $executedPaths,
public int $ccn,
public float|int $coverage,
public int|string $crap,
public readonly string $link,
) {
}
}
35 changes: 35 additions & 0 deletions src/Data/ProcessedFunctionType.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?php declare(strict_types=1);
/*
* This file is part of phpunit/php-code-coverage.
*
* (c) Sebastian Bergmann <sebastian@phpunit.de>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace SebastianBergmann\CodeCoverage\Data;

/**
* @internal This class is not covered by the backward compatibility promise for phpunit/php-code-coverage
*/
final class ProcessedFunctionType
{
public function __construct(
public readonly string $functionName,
public readonly string $namespace,
public readonly string $signature,
public readonly int $startLine,
public readonly int $endLine,
public int $executableLines,
public int $executedLines,
public int $executableBranches,
public int $executedBranches,
public int $executablePaths,
public int $executedPaths,
public int $ccn,
public float|int $coverage,
public int|string $crap,
public readonly string $link,
) {
}
}
35 changes: 35 additions & 0 deletions src/Data/ProcessedMethodType.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?php declare(strict_types=1);
/*
* This file is part of phpunit/php-code-coverage.
*
* (c) Sebastian Bergmann <sebastian@phpunit.de>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace SebastianBergmann\CodeCoverage\Data;

/**
* @internal This class is not covered by the backward compatibility promise for phpunit/php-code-coverage
*/
final class ProcessedMethodType
{
public function __construct(
public readonly string $methodName,
public readonly string $visibility,
public readonly string $signature,
public readonly int $startLine,
public readonly int $endLine,
public int $executableLines,
public int $executedLines,
public int $executableBranches,
public int $executedBranches,
public int $executablePaths,
public int $executedPaths,
public int $ccn,
public float|int $coverage,
public int|string $crap,
public readonly string $link,
) {
}
}
37 changes: 37 additions & 0 deletions src/Data/ProcessedTraitType.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?php declare(strict_types=1);
/*
* This file is part of phpunit/php-code-coverage.
*
* (c) Sebastian Bergmann <sebastian@phpunit.de>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace SebastianBergmann\CodeCoverage\Data;

/**
* @internal This class is not covered by the backward compatibility promise for phpunit/php-code-coverage
*/
final class ProcessedTraitType
{
public function __construct(
public readonly string $traitName,
public readonly string $namespace,
/**
* @var array<string, ProcessedMethodType>
*/
public array $methods,
public readonly int $startLine,
public int $executableLines,
public int $executedLines,
public int $executableBranches,
public int $executedBranches,
public int $executablePaths,
public int $executedPaths,
public int $ccn,
public float|int $coverage,
public int|string $crap,
public readonly string $link,
) {
}
}
11 changes: 5 additions & 6 deletions src/Node/AbstractNode.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,14 @@
use function str_replace;
use function substr;
use Countable;
use SebastianBergmann\CodeCoverage\Data\ProcessedClassType;
use SebastianBergmann\CodeCoverage\Data\ProcessedFunctionType;
use SebastianBergmann\CodeCoverage\Data\ProcessedTraitType;
use SebastianBergmann\CodeCoverage\StaticAnalysis\LinesOfCode;
use SebastianBergmann\CodeCoverage\Util\Percentage;

/**
* @internal This class is not covered by the backward compatibility promise for phpunit/php-code-coverage
*
* @phpstan-import-type ProcessedFunctionType from File
* @phpstan-import-type ProcessedClassType from File
* @phpstan-import-type ProcessedTraitType from File
*/
abstract class AbstractNode implements Countable
{
Expand Down Expand Up @@ -186,11 +185,11 @@ public function cyclomaticComplexity(): int
$ccn = 0;

foreach ($this->classesAndTraits() as $classLike) {
$ccn += $classLike['ccn'];
$ccn += $classLike->ccn;
}

foreach ($this->functions() as $function) {
$ccn += $function['ccn'];
$ccn += $function->ccn;
}

return $ccn;
Expand Down
7 changes: 3 additions & 4 deletions src/Node/Directory.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,14 @@
use function count;
use IteratorAggregate;
use RecursiveIteratorIterator;
use SebastianBergmann\CodeCoverage\Data\ProcessedClassType;
use SebastianBergmann\CodeCoverage\Data\ProcessedFunctionType;
use SebastianBergmann\CodeCoverage\Data\ProcessedTraitType;
use SebastianBergmann\CodeCoverage\StaticAnalysis\LinesOfCode;

/**
* @template-implements IteratorAggregate<int, AbstractNode>
*
* @phpstan-import-type ProcessedFunctionType from File
* @phpstan-import-type ProcessedClassType from File
* @phpstan-import-type ProcessedTraitType from File
*
* @internal This class is not covered by the backward compatibility promise for phpunit/php-code-coverage
*/
final class Directory extends AbstractNode implements IteratorAggregate
Expand Down
Loading