First Commit

This commit is contained in:
Esteban
2026-07-03 16:27:34 +02:00
commit 7a7440daab
8955 changed files with 1117958 additions and 0 deletions
@@ -0,0 +1,121 @@
<?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\StaticAnalysis;
/**
* @phpstan-type LinesType array<int, int>
*
* @internal This class is not covered by the backward compatibility promise for phpunit/php-code-coverage
*/
final readonly class AnalysisResult
{
/**
* @var array<string, Interface_>
*/
private array $interfaces;
/**
* @var array<string, Class_>
*/
private array $classes;
/**
* @var array<string, Trait_>
*/
private array $traits;
/**
* @var array<string, Function_>
*/
private array $functions;
private LinesOfCode $linesOfCode;
/**
* @var LinesType
*/
private array $executableLines;
/**
* @var LinesType
*/
private array $ignoredLines;
/**
* @param array<string, Interface_> $interfaces
* @param array<string, Class_> $classes
* @param array<string, Trait_> $traits
* @param array<string, Function_> $functions
* @param LinesType $executableLines
* @param LinesType $ignoredLines
*/
public function __construct(array $interfaces, array $classes, array $traits, array $functions, LinesOfCode $linesOfCode, array $executableLines, array $ignoredLines)
{
$this->interfaces = $interfaces;
$this->classes = $classes;
$this->traits = $traits;
$this->functions = $functions;
$this->linesOfCode = $linesOfCode;
$this->executableLines = $executableLines;
$this->ignoredLines = $ignoredLines;
}
/**
* @return array<string, Interface_>
*/
public function interfaces(): array
{
return $this->interfaces;
}
/**
* @return array<string, Class_>
*/
public function classes(): array
{
return $this->classes;
}
/**
* @return array<string, Trait_>
*/
public function traits(): array
{
return $this->traits;
}
/**
* @return array<string, Function_>
*/
public function functions(): array
{
return $this->functions;
}
public function linesOfCode(): LinesOfCode
{
return $this->linesOfCode;
}
/**
* @return LinesType
*/
public function executableLines(): array
{
return $this->executableLines;
}
/**
* @return LinesType
*/
public function ignoredLines(): array
{
return $this->ignoredLines;
}
}
@@ -0,0 +1,174 @@
<?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\StaticAnalysis;
/**
* @internal This class is not covered by the backward compatibility promise for phpunit/php-code-coverage
*/
final readonly class Class_
{
/**
* @var non-empty-string
*/
private string $name;
/**
* @var non-empty-string
*/
private string $namespacedName;
private string $namespace;
/**
* @var non-empty-string
*/
private string $file;
/**
* @var non-negative-int
*/
private int $startLine;
/**
* @var non-negative-int
*/
private int $endLine;
/**
* @var ?non-empty-string
*/
private ?string $parentClass;
/**
* @var list<non-empty-string>
*/
private array $interfaces;
/**
* @var list<non-empty-string>
*/
private array $traits;
/**
* @var array<non-empty-string, Method>
*/
private array $methods;
/**
* @param non-empty-string $name
* @param non-empty-string $namespacedName
* @param non-empty-string $file
* @param non-negative-int $startLine
* @param non-negative-int $endLine
* @param ?non-empty-string $parentClass
* @param list<non-empty-string> $interfaces
* @param list<non-empty-string> $traits
* @param array<non-empty-string, Method> $methods
*/
public function __construct(string $name, string $namespacedName, string $namespace, string $file, int $startLine, int $endLine, ?string $parentClass, array $interfaces, array $traits, array $methods)
{
$this->name = $name;
$this->namespacedName = $namespacedName;
$this->namespace = $namespace;
$this->file = $file;
$this->startLine = $startLine;
$this->endLine = $endLine;
$this->parentClass = $parentClass;
$this->interfaces = $interfaces;
$this->traits = $traits;
$this->methods = $methods;
}
/**
* @return non-empty-string
*/
public function name(): string
{
return $this->name;
}
/**
* @return non-empty-string
*/
public function namespacedName(): string
{
return $this->namespacedName;
}
public function isNamespaced(): bool
{
return $this->namespace !== '';
}
public function namespace(): string
{
return $this->namespace;
}
/**
* @return non-empty-string
*/
public function file(): string
{
return $this->file;
}
/**
* @return non-negative-int
*/
public function startLine(): int
{
return $this->startLine;
}
/**
* @return non-negative-int
*/
public function endLine(): int
{
return $this->endLine;
}
public function hasParent(): bool
{
return $this->parentClass !== null;
}
/**
* @return ?non-empty-string
*/
public function parentClass(): ?string
{
return $this->parentClass;
}
/**
* @return list<non-empty-string>
*/
public function interfaces(): array
{
return $this->interfaces;
}
/**
* @return list<non-empty-string>
*/
public function traits(): array
{
return $this->traits;
}
/**
* @return array<non-empty-string, Method>
*/
public function methods(): array
{
return $this->methods;
}
}
@@ -0,0 +1,124 @@
<?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\StaticAnalysis;
/**
* @internal This class is not covered by the backward compatibility promise for phpunit/php-code-coverage
*/
final readonly class Function_
{
/**
* @var non-empty-string
*/
private string $name;
/**
* @var non-empty-string
*/
private string $namespacedName;
private string $namespace;
/**
* @var non-negative-int
*/
private int $startLine;
/**
* @var non-negative-int
*/
private int $endLine;
/**
* @var non-empty-string
*/
private string $signature;
/**
* @var positive-int
*/
private int $cyclomaticComplexity;
/**
* @param non-empty-string $name
* @param non-empty-string $namespacedName
* @param non-negative-int $startLine
* @param non-negative-int $endLine
* @param non-empty-string $signature
* @param positive-int $cyclomaticComplexity
*/
public function __construct(string $name, string $namespacedName, string $namespace, int $startLine, int $endLine, string $signature, int $cyclomaticComplexity)
{
$this->name = $name;
$this->namespacedName = $namespacedName;
$this->namespace = $namespace;
$this->startLine = $startLine;
$this->endLine = $endLine;
$this->signature = $signature;
$this->cyclomaticComplexity = $cyclomaticComplexity;
}
/**
* @return non-empty-string
*/
public function name(): string
{
return $this->name;
}
/**
* @return non-empty-string
*/
public function namespacedName(): string
{
return $this->namespacedName;
}
public function isNamespaced(): bool
{
return $this->namespace !== '';
}
public function namespace(): string
{
return $this->namespace;
}
/**
* @return non-negative-int
*/
public function startLine(): int
{
return $this->startLine;
}
/**
* @return non-negative-int
*/
public function endLine(): int
{
return $this->endLine;
}
/**
* @return non-empty-string
*/
public function signature(): string
{
return $this->signature;
}
/**
* @return positive-int
*/
public function cyclomaticComplexity(): int
{
return $this->cyclomaticComplexity;
}
}
@@ -0,0 +1,109 @@
<?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\StaticAnalysis;
/**
* @internal This class is not covered by the backward compatibility promise for phpunit/php-code-coverage
*/
final readonly class Interface_
{
/**
* @var non-empty-string
*/
private string $name;
/**
* @var non-empty-string
*/
private string $namespacedName;
private string $namespace;
/**
* @var non-negative-int
*/
private int $startLine;
/**
* @var non-negative-int
*/
private int $endLine;
/**
* @var list<non-empty-string>
*/
private array $parentInterfaces;
/**
* @param non-empty-string $name
* @param non-empty-string $namespacedName
* @param non-negative-int $startLine
* @param non-negative-int $endLine
* @param list<non-empty-string> $parentInterfaces
*/
public function __construct(string $name, string $namespacedName, string $namespace, int $startLine, int $endLine, array $parentInterfaces)
{
$this->name = $name;
$this->namespacedName = $namespacedName;
$this->namespace = $namespace;
$this->startLine = $startLine;
$this->endLine = $endLine;
$this->parentInterfaces = $parentInterfaces;
}
/**
* @return non-empty-string
*/
public function name(): string
{
return $this->name;
}
/**
* @return non-empty-string
*/
public function namespacedName(): string
{
return $this->namespacedName;
}
public function isNamespaced(): bool
{
return $this->namespace !== '';
}
public function namespace(): string
{
return $this->namespace;
}
/**
* @return non-negative-int
*/
public function startLine(): int
{
return $this->startLine;
}
/**
* @return non-negative-int
*/
public function endLine(): int
{
return $this->endLine;
}
/**
* @return list<non-empty-string>
*/
public function parentInterfaces(): array
{
return $this->parentInterfaces;
}
}
@@ -0,0 +1,67 @@
<?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\StaticAnalysis;
/**
* @internal This class is not covered by the backward compatibility promise for phpunit/php-code-coverage
*/
final readonly class LinesOfCode
{
/**
* @var non-negative-int
*/
private int $linesOfCode;
/**
* @var non-negative-int
*/
private int $commentLinesOfCode;
/**
* @var non-negative-int
*/
private int $nonCommentLinesOfCode;
/**
* @param non-negative-int $linesOfCode
* @param non-negative-int $commentLinesOfCode
* @param non-negative-int $nonCommentLinesOfCode
*/
public function __construct(int $linesOfCode, int $commentLinesOfCode, int $nonCommentLinesOfCode)
{
$this->linesOfCode = $linesOfCode;
$this->commentLinesOfCode = $commentLinesOfCode;
$this->nonCommentLinesOfCode = $nonCommentLinesOfCode;
}
/**
* @return non-negative-int
*/
public function linesOfCode(): int
{
return $this->linesOfCode;
}
/**
* @return non-negative-int
*/
public function commentLinesOfCode(): int
{
return $this->commentLinesOfCode;
}
/**
* @return non-negative-int
*/
public function nonCommentLinesOfCode(): int
{
return $this->nonCommentLinesOfCode;
}
}
@@ -0,0 +1,104 @@
<?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\StaticAnalysis;
/**
* @internal This class is not covered by the backward compatibility promise for phpunit/php-code-coverage
*/
final readonly class Method
{
/**
* @var non-empty-string
*/
private string $name;
/**
* @var non-negative-int
*/
private int $startLine;
/**
* @var non-negative-int
*/
private int $endLine;
private Visibility $visibility;
/**
* @var non-empty-string
*/
private string $signature;
/**
* @var positive-int
*/
private int $cyclomaticComplexity;
/**
* @param non-empty-string $name
* @param non-negative-int $startLine
* @param non-negative-int $endLine
* @param non-empty-string $signature
* @param positive-int $cyclomaticComplexity
*/
public function __construct(string $name, int $startLine, int $endLine, string $signature, Visibility $visibility, int $cyclomaticComplexity)
{
$this->name = $name;
$this->startLine = $startLine;
$this->endLine = $endLine;
$this->signature = $signature;
$this->visibility = $visibility;
$this->cyclomaticComplexity = $cyclomaticComplexity;
}
/**
* @return non-empty-string
*/
public function name(): string
{
return $this->name;
}
/**
* @return non-negative-int
*/
public function startLine(): int
{
return $this->startLine;
}
/**
* @return non-negative-int
*/
public function endLine(): int
{
return $this->endLine;
}
/**
* @return non-empty-string
*/
public function signature(): string
{
return $this->signature;
}
public function visibility(): Visibility
{
return $this->visibility;
}
/**
* @return positive-int
*/
public function cyclomaticComplexity(): int
{
return $this->cyclomaticComplexity;
}
}
@@ -0,0 +1,139 @@
<?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\StaticAnalysis;
/**
* @internal This class is not covered by the backward compatibility promise for phpunit/php-code-coverage
*/
final readonly class Trait_
{
/**
* @var non-empty-string
*/
private string $name;
/**
* @var non-empty-string
*/
private string $namespacedName;
private string $namespace;
/**
* @var non-empty-string
*/
private string $file;
/**
* @var non-negative-int
*/
private int $startLine;
/**
* @var non-negative-int
*/
private int $endLine;
/**
* @var list<non-empty-string>
*/
private array $traits;
/**
* @var array<non-empty-string, Method>
*/
private array $methods;
/**
* @param non-empty-string $name
* @param non-empty-string $namespacedName
* @param non-empty-string $file
* @param non-negative-int $startLine
* @param non-negative-int $endLine
* @param list<non-empty-string> $traits
* @param array<non-empty-string, Method> $methods
*/
public function __construct(string $name, string $namespacedName, string $namespace, string $file, int $startLine, int $endLine, array $traits, array $methods)
{
$this->name = $name;
$this->namespacedName = $namespacedName;
$this->namespace = $namespace;
$this->file = $file;
$this->startLine = $startLine;
$this->endLine = $endLine;
$this->traits = $traits;
$this->methods = $methods;
}
/**
* @return non-empty-string
*/
public function name(): string
{
return $this->name;
}
/**
* @return non-empty-string
*/
public function namespacedName(): string
{
return $this->namespacedName;
}
public function isNamespaced(): bool
{
return $this->namespace !== '';
}
public function namespace(): string
{
return $this->namespace;
}
/**
* @return non-empty-string
*/
public function file(): string
{
return $this->file;
}
/**
* @return non-negative-int
*/
public function startLine(): int
{
return $this->startLine;
}
/**
* @return non-negative-int
*/
public function endLine(): int
{
return $this->endLine;
}
/**
* @return list<non-empty-string>
*/
public function traits(): array
{
return $this->traits;
}
/**
* @return array<non-empty-string, Method>
*/
public function methods(): array
{
return $this->methods;
}
}
@@ -0,0 +1,20 @@
<?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\StaticAnalysis;
/**
* @internal This enumeration is not covered by the backward compatibility promise for phpunit/php-code-coverage
*/
enum Visibility: string
{
case Public = 'public';
case Protected = 'protected';
case Private = 'private';
}