Skip to content

Commit a585c34

Browse files
authored
Move to readonly classes (#933)
1 parent 414b34f commit a585c34

16 files changed

+58
-58
lines changed

composer.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,13 @@
4040
"ext-simplexml": "*",
4141
"fidry/cpu-core-counter": "^1.2.0",
4242
"jean85/pretty-package-versions": "^2.1.0",
43-
"phpunit/php-code-coverage": "^11.0.8 || ^12",
43+
"phpunit/php-code-coverage": "^11.0.9 || ^12.0.4",
4444
"phpunit/php-file-iterator": "^5.1.0 || ^6",
4545
"phpunit/php-timer": "^7.0.1 || ^8",
46-
"phpunit/phpunit": "^11.5.7 || ^12.0.1",
46+
"phpunit/phpunit": "^11.5.11 || ^12.0.6",
4747
"sebastian/environment": "^7.2.0 || ^8",
4848
"symfony/console": "^6.4.17 || ^7.2.1",
49-
"symfony/process": "^6.4.15 || ^7.2.0"
49+
"symfony/process": "^6.4.19 || ^7.2.4"
5050
},
5151
"require-dev": {
5252
"ext-pcov": "*",

src/Coverage/CoverageMerger.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@
1010
use function assert;
1111

1212
/** @internal */
13-
final class CoverageMerger
13+
final readonly class CoverageMerger
1414
{
1515
public function __construct(
16-
private readonly CodeCoverage $coverage
16+
private CodeCoverage $coverage
1717
) {
1818
}
1919

src/JUnit/LogMerger.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
*
1616
* @immutable
1717
*/
18-
final class LogMerger
18+
final readonly class LogMerger
1919
{
2020
/** @param list<SplFileInfo> $junitFiles */
2121
public function merge(array $junitFiles): ?TestSuite

src/JUnit/TestCase.php

+7-7
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,15 @@
1717
*
1818
* @immutable
1919
*/
20-
class TestCase
20+
readonly class TestCase
2121
{
2222
public function __construct(
23-
public readonly string $name,
24-
public readonly string $class,
25-
public readonly string $file,
26-
public readonly int $line,
27-
public readonly int $assertions,
28-
public readonly float $time
23+
public string $name,
24+
public string $class,
25+
public string $file,
26+
public int $line,
27+
public int $assertions,
28+
public float $time
2929
) {
3030
}
3131

src/JUnit/TestCaseWithMessage.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
*
1010
* @immutable
1111
*/
12-
final class TestCaseWithMessage extends TestCase
12+
final readonly class TestCaseWithMessage extends TestCase
1313
{
1414
public function __construct(
1515
string $name,
@@ -18,9 +18,9 @@ public function __construct(
1818
int $line,
1919
int $assertions,
2020
float $time,
21-
public readonly ?string $type,
22-
public readonly string $text,
23-
public readonly MessageType $xmlTagName
21+
public ?string $type,
22+
public string $text,
23+
public MessageType $xmlTagName
2424
) {
2525
parent::__construct($name, $class, $file, $line, $assertions, $time);
2626
}

src/JUnit/TestSuite.php

+11-11
Original file line numberDiff line numberDiff line change
@@ -16,23 +16,23 @@
1616
*
1717
* @immutable
1818
*/
19-
final class TestSuite
19+
final readonly class TestSuite
2020
{
2121
/**
2222
* @param array<string, TestSuite> $suites
2323
* @param list<TestCase> $cases
2424
*/
2525
public function __construct(
26-
public readonly string $name,
27-
public readonly int $tests,
28-
public readonly int $assertions,
29-
public readonly int $failures,
30-
public readonly int $errors,
31-
public readonly int $skipped,
32-
public readonly float $time,
33-
public readonly string $file,
34-
public readonly array $suites,
35-
public readonly array $cases
26+
public string $name,
27+
public int $tests,
28+
public int $assertions,
29+
public int $failures,
30+
public int $errors,
31+
public int $skipped,
32+
public float $time,
33+
public string $file,
34+
public array $suites,
35+
public array $cases
3636
) {
3737
}
3838

src/JUnit/Writer.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@
2121
use const ENT_XML1;
2222

2323
/** @internal */
24-
final class Writer
24+
final readonly class Writer
2525
{
2626
private const TESTSUITES_NAME = 'PHPUnit tests';
27-
private readonly DOMDocument $document;
27+
private DOMDocument $document;
2828

2929
public function __construct()
3030
{

src/Options.php

+13-13
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
*
4545
* @immutable
4646
*/
47-
final class Options
47+
final readonly class Options
4848
{
4949
public const ENV_KEY_TOKEN = 'TEST_TOKEN';
5050
public const ENV_KEY_UNIQUE_TOKEN = 'UNIQUE_TEST_TOKEN';
@@ -89,18 +89,18 @@ final class Options
8989
* @param non-empty-string $tmpDir
9090
*/
9191
public function __construct(
92-
public readonly Configuration $configuration,
93-
public readonly string $phpunit,
94-
public readonly string $cwd,
95-
public readonly int $maxBatchSize,
96-
public readonly bool $noTestTokens,
97-
public readonly ?array $passthruPhp,
98-
public readonly array $phpunitOptions,
99-
public readonly int $processes,
100-
public readonly string $runner,
101-
public readonly string $tmpDir,
102-
public readonly bool $verbose,
103-
public readonly bool $functional,
92+
public Configuration $configuration,
93+
public string $phpunit,
94+
public string $cwd,
95+
public int $maxBatchSize,
96+
public bool $noTestTokens,
97+
public ?array $passthruPhp,
98+
public array $phpunitOptions,
99+
public int $processes,
100+
public string $runner,
101+
public string $tmpDir,
102+
public bool $verbose,
103+
public bool $functional,
104104
) {
105105
$this->needsTeamcity = $configuration->outputIsTeamCity() || $configuration->hasLogfileTeamcity();
106106
}

src/Util/PhpstormHelper.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
use function str_ends_with;
1313

1414
/** @internal */
15-
final class PhpstormHelper
15+
final readonly class PhpstormHelper
1616
{
1717
/** @param array<int, string> $argv */
1818
public static function handleArgvFromPhpstorm(array &$argv, string $paratestBinary): string

src/WrapperRunner/ApplicationForWrapperWorker.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ private function bootstrap(): void
215215
try {
216216
$baseline = (new Reader())->read($baselineFile);
217217
} catch (CannotLoadBaselineException $e) {
218-
EventFacade::emitter()->testRunnerTriggeredWarning($e->getMessage());
218+
EventFacade::emitter()->testRunnerTriggeredPhpunitWarning($e->getMessage());
219219
}
220220

221221
if ($baseline !== null) {

src/WrapperRunner/ProgressPrinterOutput.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@
99
use function preg_match;
1010

1111
/** @internal */
12-
final class ProgressPrinterOutput implements Printer
12+
final readonly class ProgressPrinterOutput implements Printer
1313
{
1414
public function __construct(
15-
private readonly Printer $progressPrinter,
16-
private readonly Printer $outputPrinter,
15+
private Printer $progressPrinter,
16+
private Printer $outputPrinter,
1717
) {
1818
}
1919

src/WrapperRunner/SuiteLoader.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -42,14 +42,14 @@
4242
use function substr;
4343

4444
/** @internal */
45-
final class SuiteLoader
45+
final readonly class SuiteLoader
4646
{
47-
public readonly int $testCount;
47+
public int $testCount;
4848
/** @var list<non-empty-string> */
49-
public readonly array $tests;
49+
public array $tests;
5050

5151
public function __construct(
52-
private readonly Options $options,
52+
private Options $options,
5353
OutputInterface $output,
5454
CodeCoverageFilterRegistry $codeCoverageFilterRegistry,
5555
) {

test/RunnerResult.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@
55
namespace ParaTest\Tests;
66

77
/** @immutable */
8-
final class RunnerResult
8+
final readonly class RunnerResult
99
{
1010
public function __construct(
11-
public readonly int $exitCode,
12-
public readonly string $output
11+
public int $exitCode,
12+
public string $output
1313
) {
1414
}
1515
}

test/TmpDirCreator.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
use const DIRECTORY_SEPARATOR;
1414

15-
final class TmpDirCreator
15+
final readonly class TmpDirCreator
1616
{
1717
/** @return non-empty-string */
1818
public function create(): string

test/Unit/CustomRunner.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
use ParaTest\RunnerInterface;
88

99
/** @internal */
10-
final class CustomRunner implements RunnerInterface
10+
final readonly class CustomRunner implements RunnerInterface
1111
{
1212
public const EXIT_CODE = 99;
1313

test/Unit/WrapperRunner/WrapperRunnerTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -599,7 +599,7 @@ public function testHandleUnexpectedOutput(): void
599599
There was 1 risky test:
600600
601601
1) ParaTest\Tests\fixtures\unexpected_output\UnexpectedOutputTest::testInvalidLogic
602-
This test printed output: foobar
602+
Test code or tested code printed unexpected output: foobar
603603
604604
%s/test/fixtures/unexpected_output/UnexpectedOutputTest.php:%d
605605

0 commit comments

Comments
 (0)