Skip to content

Commit

Permalink
Move to readonly classes (#933)
Browse files Browse the repository at this point in the history
  • Loading branch information
Slamdunk authored Mar 5, 2025
1 parent 414b34f commit a585c34
Show file tree
Hide file tree
Showing 16 changed files with 58 additions and 58 deletions.
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,13 @@
"ext-simplexml": "*",
"fidry/cpu-core-counter": "^1.2.0",
"jean85/pretty-package-versions": "^2.1.0",
"phpunit/php-code-coverage": "^11.0.8 || ^12",
"phpunit/php-code-coverage": "^11.0.9 || ^12.0.4",
"phpunit/php-file-iterator": "^5.1.0 || ^6",
"phpunit/php-timer": "^7.0.1 || ^8",
"phpunit/phpunit": "^11.5.7 || ^12.0.1",
"phpunit/phpunit": "^11.5.11 || ^12.0.6",
"sebastian/environment": "^7.2.0 || ^8",
"symfony/console": "^6.4.17 || ^7.2.1",
"symfony/process": "^6.4.15 || ^7.2.0"
"symfony/process": "^6.4.19 || ^7.2.4"
},
"require-dev": {
"ext-pcov": "*",
Expand Down
4 changes: 2 additions & 2 deletions src/Coverage/CoverageMerger.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
use function assert;

/** @internal */
final class CoverageMerger
final readonly class CoverageMerger
{
public function __construct(
private readonly CodeCoverage $coverage
private CodeCoverage $coverage
) {
}

Expand Down
2 changes: 1 addition & 1 deletion src/JUnit/LogMerger.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*
* @immutable
*/
final class LogMerger
final readonly class LogMerger
{
/** @param list<SplFileInfo> $junitFiles */
public function merge(array $junitFiles): ?TestSuite
Expand Down
14 changes: 7 additions & 7 deletions src/JUnit/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@
*
* @immutable
*/
class TestCase
readonly class TestCase
{
public function __construct(
public readonly string $name,
public readonly string $class,
public readonly string $file,
public readonly int $line,
public readonly int $assertions,
public readonly float $time
public string $name,
public string $class,
public string $file,
public int $line,
public int $assertions,
public float $time
) {
}

Expand Down
8 changes: 4 additions & 4 deletions src/JUnit/TestCaseWithMessage.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
*
* @immutable
*/
final class TestCaseWithMessage extends TestCase
final readonly class TestCaseWithMessage extends TestCase
{
public function __construct(
string $name,
Expand All @@ -18,9 +18,9 @@ public function __construct(
int $line,
int $assertions,
float $time,
public readonly ?string $type,
public readonly string $text,
public readonly MessageType $xmlTagName
public ?string $type,
public string $text,
public MessageType $xmlTagName
) {
parent::__construct($name, $class, $file, $line, $assertions, $time);
}
Expand Down
22 changes: 11 additions & 11 deletions src/JUnit/TestSuite.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,23 +16,23 @@
*
* @immutable
*/
final class TestSuite
final readonly class TestSuite
{
/**
* @param array<string, TestSuite> $suites
* @param list<TestCase> $cases
*/
public function __construct(
public readonly string $name,
public readonly int $tests,
public readonly int $assertions,
public readonly int $failures,
public readonly int $errors,
public readonly int $skipped,
public readonly float $time,
public readonly string $file,
public readonly array $suites,
public readonly array $cases
public string $name,
public int $tests,
public int $assertions,
public int $failures,
public int $errors,
public int $skipped,
public float $time,
public string $file,
public array $suites,
public array $cases
) {
}

Expand Down
4 changes: 2 additions & 2 deletions src/JUnit/Writer.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@
use const ENT_XML1;

/** @internal */
final class Writer
final readonly class Writer
{
private const TESTSUITES_NAME = 'PHPUnit tests';
private readonly DOMDocument $document;
private DOMDocument $document;

public function __construct()
{
Expand Down
26 changes: 13 additions & 13 deletions src/Options.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
*
* @immutable
*/
final class Options
final readonly class Options
{
public const ENV_KEY_TOKEN = 'TEST_TOKEN';
public const ENV_KEY_UNIQUE_TOKEN = 'UNIQUE_TEST_TOKEN';
Expand Down Expand Up @@ -89,18 +89,18 @@ final class Options
* @param non-empty-string $tmpDir
*/
public function __construct(
public readonly Configuration $configuration,
public readonly string $phpunit,
public readonly string $cwd,
public readonly int $maxBatchSize,
public readonly bool $noTestTokens,
public readonly ?array $passthruPhp,
public readonly array $phpunitOptions,
public readonly int $processes,
public readonly string $runner,
public readonly string $tmpDir,
public readonly bool $verbose,
public readonly bool $functional,
public Configuration $configuration,
public string $phpunit,
public string $cwd,
public int $maxBatchSize,
public bool $noTestTokens,
public ?array $passthruPhp,
public array $phpunitOptions,
public int $processes,
public string $runner,
public string $tmpDir,
public bool $verbose,
public bool $functional,
) {
$this->needsTeamcity = $configuration->outputIsTeamCity() || $configuration->hasLogfileTeamcity();
}
Expand Down
2 changes: 1 addition & 1 deletion src/Util/PhpstormHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
use function str_ends_with;

/** @internal */
final class PhpstormHelper
final readonly class PhpstormHelper
{
/** @param array<int, string> $argv */
public static function handleArgvFromPhpstorm(array &$argv, string $paratestBinary): string
Expand Down
2 changes: 1 addition & 1 deletion src/WrapperRunner/ApplicationForWrapperWorker.php
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ private function bootstrap(): void
try {
$baseline = (new Reader())->read($baselineFile);
} catch (CannotLoadBaselineException $e) {
EventFacade::emitter()->testRunnerTriggeredWarning($e->getMessage());
EventFacade::emitter()->testRunnerTriggeredPhpunitWarning($e->getMessage());
}

if ($baseline !== null) {
Expand Down
6 changes: 3 additions & 3 deletions src/WrapperRunner/ProgressPrinterOutput.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@
use function preg_match;

/** @internal */
final class ProgressPrinterOutput implements Printer
final readonly class ProgressPrinterOutput implements Printer
{
public function __construct(
private readonly Printer $progressPrinter,
private readonly Printer $outputPrinter,
private Printer $progressPrinter,
private Printer $outputPrinter,
) {
}

Expand Down
8 changes: 4 additions & 4 deletions src/WrapperRunner/SuiteLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,14 @@
use function substr;

/** @internal */
final class SuiteLoader
final readonly class SuiteLoader
{
public readonly int $testCount;
public int $testCount;
/** @var list<non-empty-string> */
public readonly array $tests;
public array $tests;

public function __construct(
private readonly Options $options,
private Options $options,
OutputInterface $output,
CodeCoverageFilterRegistry $codeCoverageFilterRegistry,
) {
Expand Down
6 changes: 3 additions & 3 deletions test/RunnerResult.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
namespace ParaTest\Tests;

/** @immutable */
final class RunnerResult
final readonly class RunnerResult
{
public function __construct(
public readonly int $exitCode,
public readonly string $output
public int $exitCode,
public string $output
) {
}
}
2 changes: 1 addition & 1 deletion test/TmpDirCreator.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

use const DIRECTORY_SEPARATOR;

final class TmpDirCreator
final readonly class TmpDirCreator
{
/** @return non-empty-string */
public function create(): string
Expand Down
2 changes: 1 addition & 1 deletion test/Unit/CustomRunner.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
use ParaTest\RunnerInterface;

/** @internal */
final class CustomRunner implements RunnerInterface
final readonly class CustomRunner implements RunnerInterface
{
public const EXIT_CODE = 99;

Expand Down
2 changes: 1 addition & 1 deletion test/Unit/WrapperRunner/WrapperRunnerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -599,7 +599,7 @@ public function testHandleUnexpectedOutput(): void
There was 1 risky test:
1) ParaTest\Tests\fixtures\unexpected_output\UnexpectedOutputTest::testInvalidLogic
This test printed output: foobar
Test code or tested code printed unexpected output: foobar
%s/test/fixtures/unexpected_output/UnexpectedOutputTest.php:%d
Expand Down

0 comments on commit a585c34

Please sign in to comment.