Skip to content

Commit e604b33

Browse files
Narrow types
1 parent d77a326 commit e604b33

File tree

6 files changed

+140
-24
lines changed

6 files changed

+140
-24
lines changed

.psalm/baseline.xml

Lines changed: 26 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -6,30 +6,6 @@
66
</UndefinedInterfaceMethod>
77
</file>
88
<file src="src/Event/Emitter/DispatchingEmitter.php">
9-
<ArgumentTypeCoercion>
10-
<code>$file</code>
11-
<code>$file</code>
12-
<code>$file</code>
13-
<code>$file</code>
14-
<code>$file</code>
15-
<code>$file</code>
16-
<code>$file</code>
17-
<code>$line</code>
18-
<code>$line</code>
19-
<code>$line</code>
20-
<code>$line</code>
21-
<code>$line</code>
22-
<code>$line</code>
23-
<code>$line</code>
24-
<code>$message</code>
25-
<code>$message</code>
26-
<code>$message</code>
27-
<code>$message</code>
28-
<code>$message</code>
29-
<code>$message</code>
30-
<code>$message</code>
31-
<code>$message</code>
32-
</ArgumentTypeCoercion>
339
<DeprecatedClass>
3410
<code><![CDATA[Exporter::export($constructorArguments, $this->exportObjects)]]></code>
3511
<code><![CDATA[Exporter::export($value, $this->exportObjects)]]></code>
@@ -515,6 +491,7 @@
515491
</file>
516492
<file src="src/Framework/TestCase.php">
517493
<ArgumentTypeCoercion>
494+
<code><![CDATA[$e->getMessage()]]></code>
518495
<code>$mockClassName</code>
519496
<code>$originalClassName</code>
520497
<code><![CDATA[$this->expectedException]]></code>
@@ -543,6 +520,7 @@
543520
</file>
544521
<file src="src/Framework/TestRunner.php">
545522
<ArgumentTypeCoercion>
523+
<code><![CDATA[$cce->getMessage()]]></code>
546524
<code><![CDATA[$test->output()]]></code>
547525
</ArgumentTypeCoercion>
548526
<DeprecatedMethod>
@@ -793,8 +771,29 @@
793771
<file src="src/Runner/ErrorHandler.php">
794772
<ArgumentTypeCoercion>
795773
<code>$errorFile</code>
774+
<code>$errorFile</code>
775+
<code>$errorFile</code>
776+
<code>$errorFile</code>
777+
<code>$errorFile</code>
778+
<code>$errorFile</code>
779+
<code>$errorFile</code>
780+
<code>$errorFile</code>
781+
<code>$errorLine</code>
782+
<code>$errorLine</code>
783+
<code>$errorLine</code>
784+
<code>$errorLine</code>
785+
<code>$errorLine</code>
786+
<code>$errorLine</code>
787+
<code>$errorLine</code>
796788
<code>$errorLine</code>
797789
<code>$errorString</code>
790+
<code>$errorString</code>
791+
<code>$errorString</code>
792+
<code>$errorString</code>
793+
<code>$errorString</code>
794+
<code>$errorString</code>
795+
<code>$errorString</code>
796+
<code>$errorString</code>
798797
</ArgumentTypeCoercion>
799798
<MissingThrowsDocblock>
800799
<code>Issue::from($file, $line, null, $description)</code>
@@ -827,6 +826,9 @@
827826
</MissingTemplateParam>
828827
</file>
829828
<file src="src/Runner/PhptTestCase.php">
829+
<ArgumentTypeCoercion>
830+
<code>$message</code>
831+
</ArgumentTypeCoercion>
830832
<InternalClass>
831833
<code>RawCodeCoverageData::fromXdebugWithoutPathCoverage([])</code>
832834
<code>RawCodeCoverageData::fromXdebugWithoutPathCoverage([])</code>

src/Event/Emitter/DispatchingEmitter.php

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -761,6 +761,8 @@ public function testSkipped(Code\Test $test, string $message): void
761761
}
762762

763763
/**
764+
* @psalm-param non-empty-string $message
765+
*
764766
* @throws InvalidArgumentException
765767
* @throws UnknownEventTypeException
766768
*/
@@ -776,6 +778,10 @@ public function testTriggeredPhpunitDeprecation(Code\Test $test, string $message
776778
}
777779

778780
/**
781+
* @psalm-param non-empty-string $message
782+
* @psalm-param non-empty-string $file
783+
* @psalm-param positive-int $line
784+
*
779785
* @throws InvalidArgumentException
780786
* @throws UnknownEventTypeException
781787
*/
@@ -796,6 +802,10 @@ public function testTriggeredPhpDeprecation(Code\Test $test, string $message, st
796802
}
797803

798804
/**
805+
* @psalm-param non-empty-string $message
806+
* @psalm-param non-empty-string $file
807+
* @psalm-param positive-int $line
808+
*
799809
* @throws InvalidArgumentException
800810
* @throws UnknownEventTypeException
801811
*/
@@ -816,6 +826,10 @@ public function testTriggeredDeprecation(Code\Test $test, string $message, strin
816826
}
817827

818828
/**
829+
* @psalm-param non-empty-string $message
830+
* @psalm-param non-empty-string $file
831+
* @psalm-param positive-int $line
832+
*
819833
* @throws InvalidArgumentException
820834
* @throws UnknownEventTypeException
821835
*/
@@ -834,6 +848,10 @@ public function testTriggeredError(Code\Test $test, string $message, string $fil
834848
}
835849

836850
/**
851+
* @psalm-param non-empty-string $message
852+
* @psalm-param non-empty-string $file
853+
* @psalm-param positive-int $line
854+
*
837855
* @throws InvalidArgumentException
838856
* @throws UnknownEventTypeException
839857
*/
@@ -853,6 +871,10 @@ public function testTriggeredNotice(Code\Test $test, string $message, string $fi
853871
}
854872

855873
/**
874+
* @psalm-param non-empty-string $message
875+
* @psalm-param non-empty-string $file
876+
* @psalm-param positive-int $line
877+
*
856878
* @throws InvalidArgumentException
857879
* @throws UnknownEventTypeException
858880
*/
@@ -872,6 +894,10 @@ public function testTriggeredPhpNotice(Code\Test $test, string $message, string
872894
}
873895

874896
/**
897+
* @psalm-param non-empty-string $message
898+
* @psalm-param non-empty-string $file
899+
* @psalm-param positive-int $line
900+
*
875901
* @throws InvalidArgumentException
876902
* @throws UnknownEventTypeException
877903
*/
@@ -891,6 +917,10 @@ public function testTriggeredWarning(Code\Test $test, string $message, string $f
891917
}
892918

893919
/**
920+
* @psalm-param non-empty-string $message
921+
* @psalm-param non-empty-string $file
922+
* @psalm-param positive-int $line
923+
*
894924
* @throws InvalidArgumentException
895925
* @throws UnknownEventTypeException
896926
*/
@@ -910,6 +940,8 @@ public function testTriggeredPhpWarning(Code\Test $test, string $message, string
910940
}
911941

912942
/**
943+
* @psalm-param non-empty-string $message
944+
*
913945
* @throws InvalidArgumentException
914946
* @throws UnknownEventTypeException
915947
*/
@@ -925,6 +957,8 @@ public function testTriggeredPhpunitError(Code\Test $test, string $message): voi
925957
}
926958

927959
/**
960+
* @psalm-param non-empty-string $message
961+
*
928962
* @throws InvalidArgumentException
929963
* @throws UnknownEventTypeException
930964
*/

src/Event/Emitter/Emitter.php

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,30 +177,80 @@ public function testFailed(Code\Test $test, Throwable $throwable, ?ComparisonFai
177177

178178
public function testPassed(Code\Test $test): void;
179179

180+
/**
181+
* @psalm-param non-empty-string $message
182+
*/
180183
public function testConsideredRisky(Code\Test $test, string $message): void;
181184

182185
public function testMarkedAsIncomplete(Code\Test $test, Throwable $throwable): void;
183186

187+
/**
188+
* @psalm-param non-empty-string $message
189+
*/
184190
public function testSkipped(Code\Test $test, string $message): void;
185191

192+
/**
193+
* @psalm-param non-empty-string $message
194+
*/
186195
public function testTriggeredPhpunitDeprecation(Code\Test $test, string $message): void;
187196

197+
/**
198+
* @psalm-param non-empty-string $message
199+
* @psalm-param non-empty-string $file
200+
* @psalm-param positive-int $line
201+
*/
188202
public function testTriggeredPhpDeprecation(Code\Test $test, string $message, string $file, int $line, bool $suppressed, bool $ignoredByBaseline, bool $ignoredByTest): void;
189203

204+
/**
205+
* @psalm-param non-empty-string $message
206+
* @psalm-param non-empty-string $file
207+
* @psalm-param positive-int $line
208+
*/
190209
public function testTriggeredDeprecation(Code\Test $test, string $message, string $file, int $line, bool $suppressed, bool $ignoredByBaseline, bool $ignoredByTest): void;
191210

211+
/**
212+
* @psalm-param non-empty-string $message
213+
* @psalm-param non-empty-string $file
214+
* @psalm-param positive-int $line
215+
*/
192216
public function testTriggeredError(Code\Test $test, string $message, string $file, int $line, bool $suppressed): void;
193217

218+
/**
219+
* @psalm-param non-empty-string $message
220+
* @psalm-param non-empty-string $file
221+
* @psalm-param positive-int $line
222+
*/
194223
public function testTriggeredNotice(Code\Test $test, string $message, string $file, int $line, bool $suppressed, bool $ignoredByBaseline): void;
195224

225+
/**
226+
* @psalm-param non-empty-string $message
227+
* @psalm-param non-empty-string $file
228+
* @psalm-param positive-int $line
229+
*/
196230
public function testTriggeredPhpNotice(Code\Test $test, string $message, string $file, int $line, bool $suppressed, bool $ignoredByBaseline): void;
197231

232+
/**
233+
* @psalm-param non-empty-string $message
234+
* @psalm-param non-empty-string $file
235+
* @psalm-param positive-int $line
236+
*/
198237
public function testTriggeredWarning(Code\Test $test, string $message, string $file, int $line, bool $suppressed, bool $ignoredByBaseline): void;
199238

239+
/**
240+
* @psalm-param non-empty-string $message
241+
* @psalm-param non-empty-string $file
242+
* @psalm-param positive-int $line
243+
*/
200244
public function testTriggeredPhpWarning(Code\Test $test, string $message, string $file, int $line, bool $suppressed, bool $ignoredByBaseline): void;
201245

246+
/**
247+
* @psalm-param non-empty-string $message
248+
*/
202249
public function testTriggeredPhpunitError(Code\Test $test, string $message): void;
203250

251+
/**
252+
* @psalm-param non-empty-string $message
253+
*/
204254
public function testTriggeredPhpunitWarning(Code\Test $test, string $message): void;
205255

206256
/**

src/Event/Events/Test/Issue/PhpunitDeprecationTriggered.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,15 @@ final class PhpunitDeprecationTriggered implements Event
2424
{
2525
private readonly Telemetry\Info $telemetryInfo;
2626
private readonly Test $test;
27+
28+
/**
29+
* @psalm-var non-empty-string
30+
*/
2731
private readonly string $message;
2832

33+
/**
34+
* @psalm-param non-empty-string $message
35+
*/
2936
public function __construct(Telemetry\Info $telemetryInfo, Test $test, string $message)
3037
{
3138
$this->telemetryInfo = $telemetryInfo;
@@ -43,6 +50,9 @@ public function test(): Test
4350
return $this->test;
4451
}
4552

53+
/**
54+
* @psalm-return non-empty-string
55+
*/
4656
public function message(): string
4757
{
4858
return $this->message;

src/Event/Events/Test/Issue/PhpunitErrorTriggered.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,15 @@ final class PhpunitErrorTriggered implements Event
2525
{
2626
private readonly Telemetry\Info $telemetryInfo;
2727
private readonly Test $test;
28+
29+
/**
30+
* @psalm-var non-empty-string
31+
*/
2832
private readonly string $message;
2933

34+
/**
35+
* @psalm-param non-empty-string $message
36+
*/
3037
public function __construct(Telemetry\Info $telemetryInfo, Test $test, string $message)
3138
{
3239
$this->telemetryInfo = $telemetryInfo;
@@ -44,6 +51,9 @@ public function test(): Test
4451
return $this->test;
4552
}
4653

54+
/**
55+
* @psalm-return non-empty-string
56+
*/
4757
public function message(): string
4858
{
4959
return $this->message;

src/Event/Events/Test/Issue/PhpunitWarningTriggered.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,15 @@ final class PhpunitWarningTriggered implements Event
2424
{
2525
private readonly Telemetry\Info $telemetryInfo;
2626
private readonly Test $test;
27+
28+
/**
29+
* @psalm-var non-empty-string
30+
*/
2731
private readonly string $message;
2832

33+
/**
34+
* @psalm-param non-empty-string $message
35+
*/
2936
public function __construct(Telemetry\Info $telemetryInfo, Test $test, string $message)
3037
{
3138
$this->telemetryInfo = $telemetryInfo;
@@ -43,6 +50,9 @@ public function test(): Test
4350
return $this->test;
4451
}
4552

53+
/**
54+
* @psalm-return non-empty-string
55+
*/
4656
public function message(): string
4757
{
4858
return $this->message;

0 commit comments

Comments
 (0)