Composer data update
This commit is contained in:
@@ -167,6 +167,8 @@ final class CodeCoverage
|
||||
$this->processUncoveredFilesFromFilter();
|
||||
} elseif ($this->includeUncoveredFiles) {
|
||||
$this->addUncoveredFilesFromFilter();
|
||||
} else {
|
||||
$this->data->removeFilesWithNoCoverage();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -9,7 +9,14 @@
|
||||
*/
|
||||
namespace SebastianBergmann\CodeCoverage\Driver;
|
||||
|
||||
use const pcov\inclusive;
|
||||
use function array_intersect;
|
||||
use function extension_loaded;
|
||||
use function pcov\clear;
|
||||
use function pcov\collect;
|
||||
use function pcov\start;
|
||||
use function pcov\stop;
|
||||
use function pcov\waiting;
|
||||
use function phpversion;
|
||||
use SebastianBergmann\CodeCoverage\Filter;
|
||||
use SebastianBergmann\CodeCoverage\RawCodeCoverageData;
|
||||
@@ -38,21 +45,27 @@ final class PcovDriver extends Driver
|
||||
|
||||
public function start(): void
|
||||
{
|
||||
\pcov\start();
|
||||
start();
|
||||
}
|
||||
|
||||
public function stop(): RawCodeCoverageData
|
||||
{
|
||||
\pcov\stop();
|
||||
stop();
|
||||
|
||||
$collect = \pcov\collect(
|
||||
\pcov\inclusive,
|
||||
!$this->filter->isEmpty() ? $this->filter->files() : \pcov\waiting()
|
||||
);
|
||||
$filesToCollectCoverageFor = waiting();
|
||||
$collected = [];
|
||||
|
||||
\pcov\clear();
|
||||
if ($filesToCollectCoverageFor) {
|
||||
if (!$this->filter->isEmpty()) {
|
||||
$filesToCollectCoverageFor = array_intersect($filesToCollectCoverageFor, $this->filter->files());
|
||||
}
|
||||
|
||||
return RawCodeCoverageData::fromXdebugWithoutPathCoverage($collect);
|
||||
$collected = collect(inclusive, $filesToCollectCoverageFor);
|
||||
|
||||
clear();
|
||||
}
|
||||
|
||||
return RawCodeCoverageData::fromXdebugWithoutPathCoverage($collected);
|
||||
}
|
||||
|
||||
public function nameAndVersion(): string
|
||||
|
||||
@@ -132,6 +132,18 @@ final class ProcessedCodeCoverageData
|
||||
unset($this->lineCoverage[$oldFile], $this->functionCoverage[$oldFile]);
|
||||
}
|
||||
|
||||
public function removeFilesWithNoCoverage(): void
|
||||
{
|
||||
foreach ($this->lineCoverage as $file => $lines) {
|
||||
foreach ($lines as $line) {
|
||||
if (is_array($line) && !empty($line)) {
|
||||
continue 2;
|
||||
}
|
||||
}
|
||||
unset($file);
|
||||
}
|
||||
}
|
||||
|
||||
public function merge(self $newData): void
|
||||
{
|
||||
foreach ($newData->lineCoverage as $file => $lines) {
|
||||
|
||||
@@ -13,11 +13,14 @@ use function implode;
|
||||
use function rtrim;
|
||||
use function trim;
|
||||
use PhpParser\Node;
|
||||
use PhpParser\Node\ComplexType;
|
||||
use PhpParser\Node\Identifier;
|
||||
use PhpParser\Node\IntersectionType;
|
||||
use PhpParser\Node\Name;
|
||||
use PhpParser\Node\NullableType;
|
||||
use PhpParser\Node\Stmt\Class_;
|
||||
use PhpParser\Node\Stmt\ClassMethod;
|
||||
use PhpParser\Node\Stmt\Enum_;
|
||||
use PhpParser\Node\Stmt\Function_;
|
||||
use PhpParser\Node\Stmt\Interface_;
|
||||
use PhpParser\Node\Stmt\Trait_;
|
||||
@@ -32,21 +35,21 @@ use SebastianBergmann\Complexity\CyclomaticComplexityCalculatingVisitor;
|
||||
final class CodeUnitFindingVisitor extends NodeVisitorAbstract
|
||||
{
|
||||
/**
|
||||
* @var array
|
||||
* @psalm-var array<string,array{name: string, namespacedName: string, namespace: string, startLine: int, endLine: int, methods: array<string,array{methodName: string, signature: string, visibility: string, startLine: int, endLine: int, ccn: int}>}>
|
||||
*/
|
||||
private $classes = [];
|
||||
|
||||
/**
|
||||
* @var array
|
||||
* @psalm-var array<string,array{name: string, namespacedName: string, namespace: string, startLine: int, endLine: int, methods: array<string,array{methodName: string, signature: string, visibility: string, startLine: int, endLine: int, ccn: int}>}>
|
||||
*/
|
||||
private $traits = [];
|
||||
|
||||
/**
|
||||
* @var array
|
||||
* @psalm-var array<string,array{name: string, namespacedName: string, namespace: string, signature: string, startLine: int, endLine: int, ccn: int}>
|
||||
*/
|
||||
private $functions = [];
|
||||
|
||||
public function enterNode(Node $node)
|
||||
public function enterNode(Node $node): void
|
||||
{
|
||||
if ($node instanceof Class_) {
|
||||
if ($node->isAnonymous()) {
|
||||
@@ -61,7 +64,7 @@ final class CodeUnitFindingVisitor extends NodeVisitorAbstract
|
||||
}
|
||||
|
||||
if (!$node instanceof ClassMethod && !$node instanceof Function_) {
|
||||
return null;
|
||||
return;
|
||||
}
|
||||
|
||||
if ($node instanceof ClassMethod) {
|
||||
@@ -79,16 +82,25 @@ final class CodeUnitFindingVisitor extends NodeVisitorAbstract
|
||||
$this->processFunction($node);
|
||||
}
|
||||
|
||||
/**
|
||||
* @psalm-return array<string,array{name: string, namespacedName: string, namespace: string, startLine: int, endLine: int, methods: array<string,array{methodName: string, signature: string, visibility: string, startLine: int, endLine: int, ccn: int}>}>
|
||||
*/
|
||||
public function classes(): array
|
||||
{
|
||||
return $this->classes;
|
||||
}
|
||||
|
||||
/**
|
||||
* @psalm-return array<string,array{name: string, namespacedName: string, namespace: string, startLine: int, endLine: int, methods: array<string,array{methodName: string, signature: string, visibility: string, startLine: int, endLine: int, ccn: int}>}>
|
||||
*/
|
||||
public function traits(): array
|
||||
{
|
||||
return $this->traits;
|
||||
}
|
||||
|
||||
/**
|
||||
* @psalm-return array<string,array{name: string, namespacedName: string, namespace: string, signature: string, startLine: int, endLine: int, ccn: int}>
|
||||
*/
|
||||
public function functions(): array
|
||||
{
|
||||
return $this->functions;
|
||||
@@ -157,24 +169,18 @@ final class CodeUnitFindingVisitor extends NodeVisitorAbstract
|
||||
}
|
||||
|
||||
/**
|
||||
* @psalm-param Identifier|Name|NullableType|UnionType $type
|
||||
* @psalm-param Identifier|Name|ComplexType $type
|
||||
*/
|
||||
private function type(Node $type): string
|
||||
{
|
||||
assert($type instanceof Identifier || $type instanceof Name || $type instanceof NullableType || $type instanceof UnionType);
|
||||
assert($type instanceof Identifier || $type instanceof Name || $type instanceof ComplexType);
|
||||
|
||||
if ($type instanceof NullableType) {
|
||||
return '?' . $type->type;
|
||||
}
|
||||
|
||||
if ($type instanceof UnionType) {
|
||||
$types = [];
|
||||
|
||||
foreach ($type->types as $_type) {
|
||||
$types[] = $_type->toString();
|
||||
}
|
||||
|
||||
return implode('|', $types);
|
||||
if ($type instanceof UnionType || $type instanceof IntersectionType) {
|
||||
return $this->unionOrIntersectionAsString($type);
|
||||
}
|
||||
|
||||
return $type->toString();
|
||||
@@ -200,7 +206,7 @@ final class CodeUnitFindingVisitor extends NodeVisitorAbstract
|
||||
|
||||
$this->classes[$namespacedName] = [
|
||||
'name' => $name,
|
||||
'namespacedName' => $namespacedName,
|
||||
'namespacedName' => (string) $namespacedName,
|
||||
'namespace' => $this->namespace($namespacedName, $name),
|
||||
'startLine' => $node->getStartLine(),
|
||||
'endLine' => $node->getEndLine(),
|
||||
@@ -215,7 +221,7 @@ final class CodeUnitFindingVisitor extends NodeVisitorAbstract
|
||||
|
||||
$this->traits[$namespacedName] = [
|
||||
'name' => $name,
|
||||
'namespacedName' => $namespacedName,
|
||||
'namespacedName' => (string) $namespacedName,
|
||||
'namespace' => $this->namespace($namespacedName, $name),
|
||||
'startLine' => $node->getStartLine(),
|
||||
'endLine' => $node->getEndLine(),
|
||||
@@ -231,7 +237,7 @@ final class CodeUnitFindingVisitor extends NodeVisitorAbstract
|
||||
return;
|
||||
}
|
||||
|
||||
assert($parentNode instanceof Class_ || $parentNode instanceof Trait_);
|
||||
assert($parentNode instanceof Class_ || $parentNode instanceof Trait_ || $parentNode instanceof Enum_);
|
||||
assert(isset($parentNode->name));
|
||||
assert(isset($parentNode->namespacedName));
|
||||
assert($parentNode->namespacedName instanceof Name);
|
||||
@@ -290,4 +296,28 @@ final class CodeUnitFindingVisitor extends NodeVisitorAbstract
|
||||
{
|
||||
return trim(rtrim($namespacedName, $name), '\\');
|
||||
}
|
||||
|
||||
/**
|
||||
* @psalm-param UnionType|IntersectionType $type
|
||||
*/
|
||||
private function unionOrIntersectionAsString(ComplexType $type): string
|
||||
{
|
||||
if ($type instanceof UnionType) {
|
||||
$separator = '|';
|
||||
} else {
|
||||
$separator = '&';
|
||||
}
|
||||
|
||||
$types = [];
|
||||
|
||||
foreach ($type->types as $_type) {
|
||||
if ($_type instanceof Name) {
|
||||
$types[] = $_type->toCodeString();
|
||||
} else {
|
||||
$types[] = $_type->toString();
|
||||
}
|
||||
}
|
||||
|
||||
return implode($separator, $types);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ final class Version
|
||||
public static function id(): string
|
||||
{
|
||||
if (self::$version === null) {
|
||||
self::$version = (new VersionId('9.2.7', dirname(__DIR__)))->getVersion();
|
||||
self::$version = (new VersionId('9.2.10', dirname(__DIR__)))->getVersion();
|
||||
}
|
||||
|
||||
return self::$version;
|
||||
|
||||
Reference in New Issue
Block a user