Skip to content

Commit 98b4a60

Browse files
Narrow types
1 parent 54fdef8 commit 98b4a60

11 files changed

+58
-45
lines changed

src/Event/Emitter/DispatchingEmitter.php

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,9 @@
2727
use PHPUnit\Event\TestSuite\Sorted as TestSuiteSorted;
2828
use PHPUnit\Event\TestSuite\Started as TestSuiteStarted;
2929
use PHPUnit\Event\TestSuite\TestSuite;
30+
use PHPUnit\Framework\TestCase;
3031
use PHPUnit\TextUI\Configuration\Configuration;
32+
use SebastianBergmann\Comparator\Comparator;
3133

3234
/**
3335
* @no-named-arguments Parameter names are not covered by the backward compatibility promise for PHPUnit
@@ -367,7 +369,7 @@ public function testPreparationFailed(Code\Test $test, Throwable $throwable): vo
367369
}
368370

369371
/**
370-
* @param class-string $testClassName
372+
* @param class-string<TestCase> $testClassName
371373
*
372374
* @throws InvalidArgumentException
373375
* @throws UnknownEventTypeException
@@ -384,7 +386,7 @@ public function beforeFirstTestMethodCalled(string $testClassName, ClassMethod $
384386
}
385387

386388
/**
387-
* @param class-string $testClassName
389+
* @param class-string<TestCase> $testClassName
388390
*
389391
* @throws InvalidArgumentException
390392
* @throws UnknownEventTypeException
@@ -402,7 +404,7 @@ public function beforeFirstTestMethodErrored(string $testClassName, ClassMethod
402404
}
403405

404406
/**
405-
* @param class-string $testClassName
407+
* @param class-string<TestCase> $testClassName
406408
*
407409
* @throws InvalidArgumentException
408410
* @throws UnknownEventTypeException
@@ -420,7 +422,7 @@ public function beforeFirstTestMethodFailed(string $testClassName, ClassMethod $
420422
}
421423

422424
/**
423-
* @param class-string $testClassName
425+
* @param class-string<TestCase> $testClassName
424426
*
425427
* @throws InvalidArgumentException
426428
* @throws UnknownEventTypeException
@@ -577,7 +579,7 @@ public function testPrepared(Code\Test $test): void
577579
}
578580

579581
/**
580-
* @param class-string $className
582+
* @param class-string<Comparator> $className
581583
*
582584
* @throws InvalidArgumentException
583585
* @throws UnknownEventTypeException
@@ -1190,7 +1192,7 @@ public function afterTestMethodFinished(TestMethod $test, ClassMethod ...$called
11901192
}
11911193

11921194
/**
1193-
* @param class-string $testClassName
1195+
* @param class-string<TestCase> $testClassName
11941196
*
11951197
* @throws InvalidArgumentException
11961198
* @throws UnknownEventTypeException
@@ -1207,7 +1209,7 @@ public function afterLastTestMethodCalled(string $testClassName, ClassMethod $ca
12071209
}
12081210

12091211
/**
1210-
* @param class-string $testClassName
1212+
* @param class-string<TestCase> $testClassName
12111213
*
12121214
* @throws InvalidArgumentException
12131215
* @throws UnknownEventTypeException
@@ -1225,7 +1227,7 @@ public function afterLastTestMethodErrored(string $testClassName, ClassMethod $c
12251227
}
12261228

12271229
/**
1228-
* @param class-string $testClassName
1230+
* @param class-string<TestCase> $testClassName
12291231
*
12301232
* @throws InvalidArgumentException
12311233
* @throws UnknownEventTypeException
@@ -1243,7 +1245,7 @@ public function afterLastTestMethodFailed(string $testClassName, ClassMethod $ca
12431245
}
12441246

12451247
/**
1246-
* @param class-string $testClassName
1248+
* @param class-string<TestCase> $testClassName
12471249
*
12481250
* @throws InvalidArgumentException
12491251
* @throws UnknownEventTypeException

src/Event/Emitter/Emitter.php

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@
1515
use PHPUnit\Event\Code\TestMethod;
1616
use PHPUnit\Event\Code\Throwable;
1717
use PHPUnit\Event\TestSuite\TestSuite;
18+
use PHPUnit\Framework\TestCase;
1819
use PHPUnit\TextUI\Configuration\Configuration;
20+
use SebastianBergmann\Comparator\Comparator;
1921

2022
/**
2123
* @no-named-arguments Parameter names are not covered by the backward compatibility promise for PHPUnit
@@ -80,22 +82,22 @@ public function testPreparationErrored(Code\Test $test, Throwable $throwable): v
8082
public function testPreparationFailed(Code\Test $test, Throwable $throwable): void;
8183

8284
/**
83-
* @param class-string $testClassName
85+
* @param class-string<TestCase> $testClassName
8486
*/
8587
public function beforeFirstTestMethodCalled(string $testClassName, ClassMethod $calledMethod): void;
8688

8789
/**
88-
* @param class-string $testClassName
90+
* @param class-string<TestCase> $testClassName
8991
*/
9092
public function beforeFirstTestMethodErrored(string $testClassName, ClassMethod $calledMethod, Throwable $throwable): void;
9193

9294
/**
93-
* @param class-string $testClassName
95+
* @param class-string<TestCase> $testClassName
9496
*/
9597
public function beforeFirstTestMethodFailed(string $testClassName, ClassMethod $calledMethod, Throwable $throwable): void;
9698

9799
/**
98-
* @param class-string $testClassName
100+
* @param class-string<TestCase> $testClassName
99101
*/
100102
public function beforeFirstTestMethodFinished(string $testClassName, ClassMethod ...$calledMethods): void;
101103

@@ -118,7 +120,7 @@ public function preConditionFinished(TestMethod $test, ClassMethod ...$calledMet
118120
public function testPrepared(Code\Test $test): void;
119121

120122
/**
121-
* @param class-string $className
123+
* @param class-string<Comparator> $className
122124
*/
123125
public function testRegisteredComparator(string $className): void;
124126

@@ -267,22 +269,22 @@ public function afterTestMethodFailed(TestMethod $test, ClassMethod $calledMetho
267269
public function afterTestMethodFinished(TestMethod $test, ClassMethod ...$calledMethods): void;
268270

269271
/**
270-
* @param class-string $testClassName
272+
* @param class-string<TestCase> $testClassName
271273
*/
272274
public function afterLastTestMethodCalled(string $testClassName, ClassMethod $calledMethod): void;
273275

274276
/**
275-
* @param class-string $testClassName
277+
* @param class-string<TestCase> $testClassName
276278
*/
277279
public function afterLastTestMethodErrored(string $testClassName, ClassMethod $calledMethod, Throwable $throwable): void;
278280

279281
/**
280-
* @param class-string $testClassName
282+
* @param class-string<TestCase> $testClassName
281283
*/
282284
public function afterLastTestMethodFailed(string $testClassName, ClassMethod $calledMethod, Throwable $throwable): void;
283285

284286
/**
285-
* @param class-string $testClassName
287+
* @param class-string<TestCase> $testClassName
286288
*/
287289
public function afterLastTestMethodFinished(string $testClassName, ClassMethod ...$calledMethods): void;
288290

src/Event/Events/Test/ComparatorRegistered.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
use function sprintf;
1313
use PHPUnit\Event\Event;
1414
use PHPUnit\Event\Telemetry;
15+
use SebastianBergmann\Comparator\Comparator;
1516

1617
/**
1718
* @immutable
@@ -23,12 +24,12 @@
2324
private Telemetry\Info $telemetryInfo;
2425

2526
/**
26-
* @var class-string
27+
* @var class-string<Comparator>
2728
*/
2829
private string $className;
2930

3031
/**
31-
* @param class-string $className
32+
* @param class-string<Comparator> $className
3233
*/
3334
public function __construct(Telemetry\Info $telemetryInfo, string $className)
3435
{
@@ -42,7 +43,7 @@ public function telemetryInfo(): Telemetry\Info
4243
}
4344

4445
/**
45-
* @return class-string
46+
* @return class-string<Comparator>
4647
*/
4748
public function className(): string
4849
{

src/Event/Events/Test/HookMethod/AfterLastTestMethodCalled.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
use PHPUnit\Event\Code;
1414
use PHPUnit\Event\Event;
1515
use PHPUnit\Event\Telemetry;
16+
use PHPUnit\Framework\TestCase;
1617

1718
/**
1819
* @immutable
@@ -24,13 +25,13 @@
2425
private Telemetry\Info $telemetryInfo;
2526

2627
/**
27-
* @var class-string
28+
* @var class-string<TestCase>
2829
*/
2930
private string $testClassName;
3031
private Code\ClassMethod $calledMethod;
3132

3233
/**
33-
* @param class-string $testClassName
34+
* @param class-string<TestCase> $testClassName
3435
*/
3536
public function __construct(Telemetry\Info $telemetryInfo, string $testClassName, Code\ClassMethod $calledMethod)
3637
{
@@ -45,7 +46,7 @@ public function telemetryInfo(): Telemetry\Info
4546
}
4647

4748
/**
48-
* @return class-string
49+
* @return class-string<TestCase>
4950
*/
5051
public function testClassName(): string
5152
{

src/Event/Events/Test/HookMethod/AfterLastTestMethodErrored.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
use PHPUnit\Event\Code\Throwable;
1616
use PHPUnit\Event\Event;
1717
use PHPUnit\Event\Telemetry;
18+
use PHPUnit\Framework\TestCase;
1819

1920
/**
2021
* @immutable
@@ -26,14 +27,14 @@
2627
private Telemetry\Info $telemetryInfo;
2728

2829
/**
29-
* @var class-string
30+
* @var class-string<TestCase>
3031
*/
3132
private string $testClassName;
3233
private Code\ClassMethod $calledMethod;
3334
private Throwable $throwable;
3435

3536
/**
36-
* @param class-string $testClassName
37+
* @param class-string<TestCase> $testClassName
3738
*/
3839
public function __construct(Telemetry\Info $telemetryInfo, string $testClassName, Code\ClassMethod $calledMethod, Throwable $throwable)
3940
{
@@ -49,7 +50,7 @@ public function telemetryInfo(): Telemetry\Info
4950
}
5051

5152
/**
52-
* @return class-string
53+
* @return class-string<TestCase>
5354
*/
5455
public function testClassName(): string
5556
{

src/Event/Events/Test/HookMethod/AfterLastTestMethodFailed.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
use PHPUnit\Event\Code\Throwable;
1616
use PHPUnit\Event\Event;
1717
use PHPUnit\Event\Telemetry;
18+
use PHPUnit\Framework\TestCase;
1819

1920
/**
2021
* @immutable
@@ -26,14 +27,14 @@
2627
private Telemetry\Info $telemetryInfo;
2728

2829
/**
29-
* @var class-string
30+
* @var class-string<TestCase>
3031
*/
3132
private string $testClassName;
3233
private Code\ClassMethod $calledMethod;
3334
private Throwable $throwable;
3435

3536
/**
36-
* @param class-string $testClassName
37+
* @param class-string<TestCase> $testClassName
3738
*/
3839
public function __construct(Telemetry\Info $telemetryInfo, string $testClassName, Code\ClassMethod $calledMethod, Throwable $throwable)
3940
{
@@ -49,7 +50,7 @@ public function telemetryInfo(): Telemetry\Info
4950
}
5051

5152
/**
52-
* @return class-string
53+
* @return class-string<TestCase>
5354
*/
5455
public function testClassName(): string
5556
{

src/Event/Events/Test/HookMethod/AfterLastTestMethodFinished.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
use PHPUnit\Event\Code;
1515
use PHPUnit\Event\Event;
1616
use PHPUnit\Event\Telemetry;
17+
use PHPUnit\Framework\TestCase;
1718

1819
/**
1920
* @immutable
@@ -25,7 +26,7 @@
2526
private Telemetry\Info $telemetryInfo;
2627

2728
/**
28-
* @var class-string
29+
* @var class-string<TestCase>
2930
*/
3031
private string $testClassName;
3132

@@ -35,7 +36,7 @@
3536
private array $calledMethods;
3637

3738
/**
38-
* @param class-string $testClassName
39+
* @param class-string<TestCase> $testClassName
3940
*/
4041
public function __construct(Telemetry\Info $telemetryInfo, string $testClassName, Code\ClassMethod ...$calledMethods)
4142
{
@@ -50,7 +51,7 @@ public function telemetryInfo(): Telemetry\Info
5051
}
5152

5253
/**
53-
* @return class-string
54+
* @return class-string<TestCase>
5455
*/
5556
public function testClassName(): string
5657
{

src/Event/Events/Test/HookMethod/BeforeFirstTestMethodCalled.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
use PHPUnit\Event\Code;
1414
use PHPUnit\Event\Event;
1515
use PHPUnit\Event\Telemetry;
16+
use PHPUnit\Framework\TestCase;
1617

1718
/**
1819
* @immutable
@@ -24,13 +25,13 @@
2425
private Telemetry\Info $telemetryInfo;
2526

2627
/**
27-
* @var class-string
28+
* @var class-string<TestCase>
2829
*/
2930
private string $testClassName;
3031
private Code\ClassMethod $calledMethod;
3132

3233
/**
33-
* @param class-string $testClassName
34+
* @param class-string<TestCase> $testClassName
3435
*/
3536
public function __construct(Telemetry\Info $telemetryInfo, string $testClassName, Code\ClassMethod $calledMethod)
3637
{
@@ -45,7 +46,7 @@ public function telemetryInfo(): Telemetry\Info
4546
}
4647

4748
/**
48-
* @return class-string
49+
* @return class-string<TestCase>
4950
*/
5051
public function testClassName(): string
5152
{

src/Event/Events/Test/HookMethod/BeforeFirstTestMethodErrored.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
use PHPUnit\Event\Code\Throwable;
1616
use PHPUnit\Event\Event;
1717
use PHPUnit\Event\Telemetry;
18+
use PHPUnit\Framework\TestCase;
1819

1920
/**
2021
* @immutable
@@ -26,14 +27,14 @@
2627
private Telemetry\Info $telemetryInfo;
2728

2829
/**
29-
* @var class-string
30+
* @var class-string<TestCase>
3031
*/
3132
private string $testClassName;
3233
private Code\ClassMethod $calledMethod;
3334
private Throwable $throwable;
3435

3536
/**
36-
* @param class-string $testClassName
37+
* @param class-string<TestCase> $testClassName
3738
*/
3839
public function __construct(Telemetry\Info $telemetryInfo, string $testClassName, Code\ClassMethod $calledMethod, Throwable $throwable)
3940
{
@@ -49,7 +50,7 @@ public function telemetryInfo(): Telemetry\Info
4950
}
5051

5152
/**
52-
* @return class-string
53+
* @return class-string<TestCase>
5354
*/
5455
public function testClassName(): string
5556
{

0 commit comments

Comments
 (0)