File tree Expand file tree Collapse file tree
tests/PHPStan/Rules/Comparison Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -237,4 +237,10 @@ public function testBug6822(): void
237237 $ this ->analyse ([__DIR__ . '/../../Analyser/nsrt/bug-6822.php ' ], []);
238238 }
239239
240+ public function testBug5020 (): void
241+ {
242+ $ this ->treatPhpDocTypesAsCertain = true ;
243+ $ this ->analyse ([__DIR__ . '/data/bug-5020.php ' ], []);
244+ }
245+
240246}
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace Bug5020 ;
4+
5+ interface ITransformer
6+ {
7+ public static function Transform (string $ theInput , bool &$ theErrorEncountered ): string ;
8+ }
9+
10+ class Transformer implements ITransformer
11+ {
12+ public static function Transform (string $ theInput , bool &$ theErrorEncountered ): string
13+ {
14+ if ($ theInput === 'invalid ' ) {
15+ $ theErrorEncountered = true ;
16+ return '' ;
17+ }
18+ return strtoupper (trim ($ theInput ));
19+ }
20+ }
21+
22+ /**
23+ * @param class-string<Transformer> $transformer
24+ */
25+ function foo (string $ transformer ): void
26+ {
27+ $ input = ' asdasda asdasd ' ;
28+ $ error = false ;
29+ $ output = $ transformer ::Transform ($ input , $ error );
30+ if ($ error ) {
31+
32+ }
33+ }
You can’t perform that action at this time.
0 commit comments