Skip to content

Commit

Permalink
Reorganize
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastianbergmann committed Feb 22, 2022
1 parent 75a0f91 commit 0f89e2c
Show file tree
Hide file tree
Showing 39 changed files with 59 additions and 58 deletions.
22 changes: 11 additions & 11 deletions .psalm/baseline.xml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,17 @@
<code>waiting()</code>
</UndefinedFunction>
</file>
<file src="src/Data/ProcessedCodeCoverageData.php">
<PossiblyNullArgument occurrences="1">
<code>$this-&gt;functionCoverage[$file][$functionName]['branches'][$branchId]['hit']</code>
</PossiblyNullArgument>
<PossiblyNullArrayAccess occurrences="1">
<code>$this-&gt;functionCoverage[$file][$functionName]['branches']</code>
</PossiblyNullArrayAccess>
<PossiblyNullArrayAssignment occurrences="1">
<code>$this-&gt;functionCoverage[$file][$functionName]['branches']</code>
</PossiblyNullArrayAssignment>
</file>
<file src="src/Driver/Xdebug2Driver.php">
<UndefinedConstant occurrences="3">
<code>XDEBUG_CC_BRANCH_CHECK</code>
Expand Down Expand Up @@ -131,17 +142,6 @@
<code>$position</code>
</PropertyNotSetInConstructor>
</file>
<file src="src/ProcessedCodeCoverageData.php">
<PossiblyNullArgument occurrences="1">
<code>$this-&gt;functionCoverage[$file][$functionName]['branches'][$branchId]['hit']</code>
</PossiblyNullArgument>
<PossiblyNullArrayAccess occurrences="1">
<code>$this-&gt;functionCoverage[$file][$functionName]['branches']</code>
</PossiblyNullArrayAccess>
<PossiblyNullArrayAssignment occurrences="1">
<code>$this-&gt;functionCoverage[$file][$functionName]['branches']</code>
</PossiblyNullArrayAssignment>
</file>
<file src="src/Report/Html/Renderer/File.php">
<InternalClass occurrences="7">
<code>BaseTestRunner::STATUS_ERROR</code>
Expand Down
2 changes: 2 additions & 0 deletions src/CodeCoverage.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
use PHPUnit\Runner\PhptTestCase;
use PHPUnit\Util\Test;
use ReflectionClass;
use SebastianBergmann\CodeCoverage\Data\ProcessedCodeCoverageData;
use SebastianBergmann\CodeCoverage\Data\RawCodeCoverageData;
use SebastianBergmann\CodeCoverage\Driver\Driver;
use SebastianBergmann\CodeCoverage\Node\Builder;
use SebastianBergmann\CodeCoverage\Node\Directory;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace SebastianBergmann\CodeCoverage;
namespace SebastianBergmann\CodeCoverage\Data;

use function array_key_exists;
use function array_keys;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace SebastianBergmann\CodeCoverage;
namespace SebastianBergmann\CodeCoverage\Data;

use function array_diff;
use function array_diff_key;
Expand Down
2 changes: 1 addition & 1 deletion src/Driver/Driver.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@

use function sprintf;
use SebastianBergmann\CodeCoverage\BranchAndPathCoverageNotSupportedException;
use SebastianBergmann\CodeCoverage\Data\RawCodeCoverageData;
use SebastianBergmann\CodeCoverage\DeadCodeDetectionNotSupportedException;
use SebastianBergmann\CodeCoverage\Filter;
use SebastianBergmann\CodeCoverage\NoCodeCoverageDriverAvailableException;
use SebastianBergmann\CodeCoverage\NoCodeCoverageDriverWithPathCoverageSupportAvailableException;
use SebastianBergmann\CodeCoverage\RawCodeCoverageData;

/**
* @internal This class is not covered by the backward compatibility promise for phpunit/php-code-coverage
Expand Down
2 changes: 1 addition & 1 deletion src/Driver/PcovDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
use function pcov\stop;
use function pcov\waiting;
use function phpversion;
use SebastianBergmann\CodeCoverage\Data\RawCodeCoverageData;
use SebastianBergmann\CodeCoverage\Filter;
use SebastianBergmann\CodeCoverage\RawCodeCoverageData;

/**
* @internal This class is not covered by the backward compatibility promise for phpunit/php-code-coverage
Expand Down
2 changes: 1 addition & 1 deletion src/Driver/PhpdbgDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
use function phpdbg_end_oplog;
use function phpdbg_get_executable;
use function phpdbg_start_oplog;
use SebastianBergmann\CodeCoverage\RawCodeCoverageData;
use SebastianBergmann\CodeCoverage\Data\RawCodeCoverageData;

/**
* @internal This class is not covered by the backward compatibility promise for phpunit/php-code-coverage
Expand Down
2 changes: 1 addition & 1 deletion src/Driver/Xdebug2Driver.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
use function xdebug_set_filter;
use function xdebug_start_code_coverage;
use function xdebug_stop_code_coverage;
use SebastianBergmann\CodeCoverage\Data\RawCodeCoverageData;
use SebastianBergmann\CodeCoverage\Filter;
use SebastianBergmann\CodeCoverage\RawCodeCoverageData;

/**
* @internal This class is not covered by the backward compatibility promise for phpunit/php-code-coverage
Expand Down
2 changes: 1 addition & 1 deletion src/Driver/Xdebug3Driver.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
use function xdebug_set_filter;
use function xdebug_start_code_coverage;
use function xdebug_stop_code_coverage;
use SebastianBergmann\CodeCoverage\Data\RawCodeCoverageData;
use SebastianBergmann\CodeCoverage\Filter;
use SebastianBergmann\CodeCoverage\RawCodeCoverageData;

/**
* @internal This class is not covered by the backward compatibility promise for phpunit/php-code-coverage
Expand Down
3 changes: 2 additions & 1 deletion src/Exception/DirectoryCouldNotBeCreatedException.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace SebastianBergmann\CodeCoverage;
namespace SebastianBergmann\CodeCoverage\Util;

use RuntimeException;
use SebastianBergmann\CodeCoverage\Exception;

final class DirectoryCouldNotBeCreatedException extends RuntimeException implements Exception
{
Expand Down
2 changes: 1 addition & 1 deletion src/Node/AbstractNode.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
use function str_replace;
use function substr;
use Countable;
use SebastianBergmann\CodeCoverage\Percentage;
use SebastianBergmann\CodeCoverage\Util\Percentage;

/**
* @internal This class is not covered by the backward compatibility promise for phpunit/php-code-coverage
Expand Down
2 changes: 1 addition & 1 deletion src/Node/Builder.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
use function strpos;
use function substr;
use SebastianBergmann\CodeCoverage\CodeCoverage;
use SebastianBergmann\CodeCoverage\ProcessedCodeCoverageData;
use SebastianBergmann\CodeCoverage\Data\ProcessedCodeCoverageData;
use SebastianBergmann\CodeCoverage\StaticAnalysis\FileAnalyser;

/**
Expand Down
7 changes: 1 addition & 6 deletions src/CrapIndex.php → src/Node/CrapIndex.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace SebastianBergmann\CodeCoverage;
namespace SebastianBergmann\CodeCoverage\Node;

use function sprintf;

Expand All @@ -26,11 +26,6 @@ final class CrapIndex
*/
private $codeCoverage;

public static function fromCyclomaticComplexityAndCoveragePercentage(int $cyclomaticComplexity, float $codeCoverage): self
{
return new self($cyclomaticComplexity, $codeCoverage);
}

public function __construct(int $cyclomaticComplexity, float $codeCoverage)
{
$this->cyclomaticComplexity = $cyclomaticComplexity;
Expand Down
1 change: 0 additions & 1 deletion src/Node/File.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
use function array_filter;
use function count;
use function range;
use SebastianBergmann\CodeCoverage\CrapIndex;

/**
* @internal This class is not covered by the backward compatibility promise for phpunit/php-code-coverage
Expand Down
4 changes: 2 additions & 2 deletions src/Report/Clover.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
use function time;
use DOMDocument;
use SebastianBergmann\CodeCoverage\CodeCoverage;
use SebastianBergmann\CodeCoverage\Directory;
use SebastianBergmann\CodeCoverage\Driver\WriteOperationFailedException;
use SebastianBergmann\CodeCoverage\Node\File;
use SebastianBergmann\CodeCoverage\Util\Filesystem;

final class Clover
{
Expand Down Expand Up @@ -243,7 +243,7 @@ public function process(CodeCoverage $coverage, ?string $target = null, ?string
$buffer = $xmlDocument->saveXML();

if ($target !== null) {
Directory::create(dirname($target));
Filesystem::createDirectory(dirname($target));

if (@file_put_contents($target, $buffer) === false) {
throw new WriteOperationFailedException($target);
Expand Down
4 changes: 2 additions & 2 deletions src/Report/Cobertura.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@
use function time;
use DOMImplementation;
use SebastianBergmann\CodeCoverage\CodeCoverage;
use SebastianBergmann\CodeCoverage\Directory;
use SebastianBergmann\CodeCoverage\Driver\WriteOperationFailedException;
use SebastianBergmann\CodeCoverage\Node\File;
use SebastianBergmann\CodeCoverage\Util\Filesystem;

final class Cobertura
{
Expand Down Expand Up @@ -292,7 +292,7 @@ public function process(CodeCoverage $coverage, ?string $target = null, ?string
$buffer = $document->saveXML();

if ($target !== null) {
Directory::create(dirname($target));
Filesystem::createDirectory(dirname($target));

if (@file_put_contents($target, $buffer) === false) {
throw new WriteOperationFailedException($target);
Expand Down
4 changes: 2 additions & 2 deletions src/Report/Crap4j.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
use function round;
use DOMDocument;
use SebastianBergmann\CodeCoverage\CodeCoverage;
use SebastianBergmann\CodeCoverage\Directory;
use SebastianBergmann\CodeCoverage\Driver\WriteOperationFailedException;
use SebastianBergmann\CodeCoverage\Node\File;
use SebastianBergmann\CodeCoverage\Util\Filesystem;

final class Crap4j
{
Expand Down Expand Up @@ -124,7 +124,7 @@ public function process(CodeCoverage $coverage, ?string $target = null, ?string
$buffer = $document->saveXML();

if ($target !== null) {
Directory::create(dirname($target));
Filesystem::createDirectory(dirname($target));

if (@file_put_contents($target, $buffer) === false) {
throw new WriteOperationFailedException($target);
Expand Down
8 changes: 4 additions & 4 deletions src/Report/Html/Facade.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
use function dirname;
use function substr;
use SebastianBergmann\CodeCoverage\CodeCoverage;
use SebastianBergmann\CodeCoverage\Directory as DirectoryUtil;
use SebastianBergmann\CodeCoverage\InvalidArgumentException;
use SebastianBergmann\CodeCoverage\Node\Directory as DirectoryNode;
use SebastianBergmann\CodeCoverage\Util\Filesystem;

final class Facade
{
Expand Down Expand Up @@ -95,14 +95,14 @@ public function process(CodeCoverage $coverage, string $target): void
$id = $node->id();

if ($node instanceof DirectoryNode) {
DirectoryUtil::create($target . $id);
Filesystem::createDirectory($target . $id);

$directory->render($node, $target . $id . '/index.html');
$dashboard->render($node, $target . $id . '/dashboard.html');
} else {
$dir = dirname($target . $id);

DirectoryUtil::create($dir);
Filesystem::createDirectory($dir);

$file->render($node, $target . $id);
}
Expand Down Expand Up @@ -140,7 +140,7 @@ private function directory(string $directory): string
$directory .= DIRECTORY_SEPARATOR;
}

DirectoryUtil::create($directory);
Filesystem::createDirectory($directory);

return $directory;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Report/Html/Renderer/File.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@
use function trim;
use PHPUnit\Runner\BaseTestRunner;
use SebastianBergmann\CodeCoverage\Node\File as FileNode;
use SebastianBergmann\CodeCoverage\Percentage;
use SebastianBergmann\CodeCoverage\Util\Percentage;
use SebastianBergmann\Template\Template;

/**
Expand Down
4 changes: 2 additions & 2 deletions src/Report/PHP.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
use function serialize;
use function sprintf;
use SebastianBergmann\CodeCoverage\CodeCoverage;
use SebastianBergmann\CodeCoverage\Directory;
use SebastianBergmann\CodeCoverage\Driver\WriteOperationFailedException;
use SebastianBergmann\CodeCoverage\Util\Filesystem;

final class PHP
{
Expand All @@ -31,7 +31,7 @@ public function process(CodeCoverage $coverage, ?string $target = null): string
);

if ($target !== null) {
Directory::create(dirname($target));
Filesystem::createDirectory(dirname($target));

if (@file_put_contents($target, $buffer) === false) {
throw new WriteOperationFailedException($target);
Expand Down
2 changes: 1 addition & 1 deletion src/Report/Text.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
use function strlen;
use SebastianBergmann\CodeCoverage\CodeCoverage;
use SebastianBergmann\CodeCoverage\Node\File;
use SebastianBergmann\CodeCoverage\Percentage;
use SebastianBergmann\CodeCoverage\Util\Percentage;

final class Text
{
Expand Down
4 changes: 2 additions & 2 deletions src/Report/Xml/Facade.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@
use DateTimeImmutable;
use DOMDocument;
use SebastianBergmann\CodeCoverage\CodeCoverage;
use SebastianBergmann\CodeCoverage\Directory as DirectoryUtil;
use SebastianBergmann\CodeCoverage\Driver\PathExistsButIsNotDirectoryException;
use SebastianBergmann\CodeCoverage\Driver\WriteOperationFailedException;
use SebastianBergmann\CodeCoverage\Node\AbstractNode;
use SebastianBergmann\CodeCoverage\Node\Directory as DirectoryNode;
use SebastianBergmann\CodeCoverage\Node\File as FileNode;
use SebastianBergmann\CodeCoverage\Util\Filesystem as DirectoryUtil;
use SebastianBergmann\CodeCoverage\Version;
use SebastianBergmann\CodeCoverage\XmlException;
use SebastianBergmann\Environment\Runtime;
Expand Down Expand Up @@ -109,7 +109,7 @@ private function initTargetDirectory(string $directory): void
}
}

DirectoryUtil::create($directory);
DirectoryUtil::createDirectory($directory);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/Report/Xml/Totals.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
use function sprintf;
use DOMElement;
use DOMNode;
use SebastianBergmann\CodeCoverage\Percentage;
use SebastianBergmann\CodeCoverage\Util\Percentage;

/**
* @internal This class is not covered by the backward compatibility promise for phpunit/php-code-coverage
Expand Down
4 changes: 2 additions & 2 deletions src/StaticAnalysis/CachingFileAnalyser.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
use function file_put_contents;
use function is_file;
use function serialize;
use SebastianBergmann\CodeCoverage\Directory;
use SebastianBergmann\CodeCoverage\Util\Filesystem;

/**
* @internal This class is not covered by the backward compatibility promise for phpunit/php-code-coverage
Expand All @@ -40,7 +40,7 @@ final class CachingFileAnalyser implements FileAnalyser

public function __construct(string $directory, FileAnalyser $analyser)
{
Directory::create($directory);
Filesystem::createDirectory($directory);

$this->analyser = $analyser;
$this->directory = $directory;
Expand Down
6 changes: 3 additions & 3 deletions src/Directory.php → src/Util/Filesystem.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace SebastianBergmann\CodeCoverage;
namespace SebastianBergmann\CodeCoverage\Util;

use function is_dir;
use function mkdir;
Expand All @@ -16,12 +16,12 @@
/**
* @internal This class is not covered by the backward compatibility promise for phpunit/php-code-coverage
*/
final class Directory
final class Filesystem
{
/**
* @throws DirectoryCouldNotBeCreatedException
*/
public static function create(string $directory): void
public static function createDirectory(string $directory): void
{
$success = !(!is_dir($directory) && !@mkdir($directory, 0777, true) && !is_dir($directory));

Expand Down
2 changes: 1 addition & 1 deletion src/Percentage.php → src/Util/Percentage.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace SebastianBergmann\CodeCoverage;
namespace SebastianBergmann\CodeCoverage\Util;

use function sprintf;

Expand Down
1 change: 1 addition & 0 deletions tests/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
*/
namespace SebastianBergmann\CodeCoverage;

use SebastianBergmann\CodeCoverage\Data\RawCodeCoverageData;
use function array_merge;
use function range;
use function rmdir;
Expand Down
Loading

0 comments on commit 0f89e2c

Please sign in to comment.