File tree Expand file tree Collapse file tree 2 files changed +52
-0
lines changed
tests/PHPStan/Rules/TooWideTypehints Expand file tree Collapse file tree 2 files changed +52
-0
lines changed Original file line number Diff line number Diff line change @@ -61,6 +61,7 @@ public function testBug11667(): void
6161 $ this ->analyse ([__DIR__ . '/data/bug-11667.php ' ], []);
6262 }
6363
64+ #[RequiresPhp('>= 8.2 ' )]
6465 public function testBug13384 (): void
6566 {
6667 $ this ->reportTooWideBool = true ;
@@ -76,6 +77,24 @@ public function testBug13384(): void
7677 ]);
7778 }
7879
80+ #[RequiresPhp('< 8.2 ' )]
81+ public function testBug13384PrePhp82 (): void
82+ {
83+ $ this ->reportTooWideBool = true ;
84+ $ this ->analyse ([__DIR__ . '/data/bug-13384.php ' ], []);
85+ }
86+
87+ public function testBug13384Phpdoc (): void
88+ {
89+ $ this ->reportTooWideBool = true ;
90+ $ this ->analyse ([__DIR__ . '/data/bug-13384-phpdoc.php ' ], [
91+ [
92+ 'Static property Bug13384Phpdoc\ShutdownHandlerPhpdocTypes::$registered (bool) is never assigned true so it can be removed from the property type. ' ,
93+ 12 ,
94+ ],
95+ ]);
96+ }
97+
7998 public function testBug13384b (): void
8099 {
81100 $ this ->reportTooWideBool = true ;
Original file line number Diff line number Diff line change 1+ <?php declare (strict_types=1 );
2+
3+ namespace Bug13384Phpdoc ;
4+
5+ use function register_shutdown_function ;
6+
7+ final class ShutdownHandlerPhpdocTypes
8+ {
9+ /**
10+ * @var bool
11+ */
12+ private static $ registered = false ;
13+ private static string $ message = '' ;
14+
15+ public static function setMessage (string $ message ): void
16+ {
17+ self ::register ();
18+
19+ self ::$ message = $ message ;
20+ }
21+
22+ private static function register (): void
23+ {
24+ if (self ::$ registered ) {
25+ return ;
26+ }
27+
28+ register_shutdown_function (static function (): void
29+ {
30+ print self ::$ message ;
31+ });
32+ }
33+ }
You can’t perform that action at this time.
0 commit comments