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 @@ -296,6 +296,12 @@ public function testBug13566(): void
296296 $ this ->analyse ([__DIR__ . '/data/bug-13566.php ' ], []);
297297 }
298298
299+ public function testBug10337 (): void
300+ {
301+ $ this ->treatPhpDocTypesAsCertain = true ;
302+ $ this ->analyse ([__DIR__ . '/data/bug-10337.php ' ], []);
303+ }
304+
299305 public static function getAdditionalConfigFiles (): array
300306 {
301307 return [
Original file line number Diff line number Diff line change 1+ <?php declare (strict_types=1 );
2+
3+ namespace Bug10337 ;
4+
5+ use function PHPStan \Testing \assertType ;
6+
7+ class App
8+ {
9+ /**
10+ * @return ($calledFromShutdownHandler is true ? void : never)
11+ */
12+ public function callExit (bool $ calledFromShutdownHandler = false ): void
13+ {
14+ // run before shutdown code here
15+
16+ if (!$ calledFromShutdownHandler ) {
17+ exit ;
18+ }
19+ }
20+
21+ public function testOnlyVoid (): void
22+ {
23+ (new App ())->callExit (true );
24+ }
25+
26+ /**
27+ * @return never
28+ */
29+ public function testVoidAndNever (): void
30+ {
31+ $ app = new App ();
32+ assertType ('null ' , $ app ->callExit (true ));
33+ assertType ('never ' , $ app ->callExit (false ));
34+ }
35+
36+ /**
37+ * @return never
38+ */
39+ public function testVoidAndNever2 (): void
40+ {
41+ $ app = new class () extends App {
42+ };
43+ assertType ('null ' , $ app ->callExit (true ));
44+ assertType ('never ' , $ app ->callExit (false ));
45+ }
46+
47+ /**
48+ * @return never
49+ */
50+ public function testVoidAndNever3 (): void
51+ {
52+ $ app = new class () extends App {
53+ #[\Override]
54+ public function callExit (bool $ calledFromShutdownHandler = false ): void
55+ {
56+ parent ::callExit ($ calledFromShutdownHandler );
57+ }
58+ };
59+ assertType ('null ' , $ app ->callExit (true ));
60+ assertType ('never ' , $ app ->callExit (false ));
61+ }
62+ }
You can’t perform that action at this time.
0 commit comments