File tree Expand file tree Collapse file tree 2 files changed +58
-0
lines changed
tests/PHPStan/Rules/Functions Expand file tree Collapse file tree 2 files changed +58
-0
lines changed Original file line number Diff line number Diff line change @@ -307,6 +307,11 @@ public function testBug9614(): void
307307 $ this ->analyse ([__DIR__ . '/data/bug-9614.php ' ], []);
308308 }
309309
310+ public function testBug3616 (): void
311+ {
312+ $ this ->analyse ([__DIR__ . '/data/bug-3616.php ' ], []);
313+ }
314+
310315 public function testBug10814 (): void
311316 {
312317 $ this ->analyse ([__DIR__ . '/data/bug-10814.php ' ], [
Original file line number Diff line number Diff line change 1+ <?php declare (strict_types = 1 );
2+
3+ namespace Bug3616 ;
4+
5+ class Factory {
6+ public static function a (): void { echo 'A ' ; }
7+ public static function b (): void { echo 'B ' ; }
8+ }
9+
10+ class HelloWorld
11+ {
12+ /** @var array<string, callable():void> */
13+ const FACTORIES = [
14+ 'a ' => [Factory::class, 'a ' ],
15+ 'b ' => [Factory::class, 'b ' ]
16+ ];
17+
18+ public function withLiteral (): void
19+ {
20+ (self ::FACTORIES ['a ' ])();
21+ }
22+
23+ public function withVariable (string $ id ): void
24+ {
25+ if (!isset (self ::FACTORIES [$ id ])) {
26+ return ;
27+ }
28+
29+ (self ::FACTORIES [$ id ])();
30+ }
31+ }
32+
33+ class HelloWorld2
34+ {
35+ const FACTORIES = [
36+ 'a ' => [Factory::class, 'a ' ],
37+ 'b ' => [Factory::class, 'b ' ]
38+ ];
39+
40+ public function withLiteral (): void
41+ {
42+ (self ::FACTORIES ['a ' ])();
43+ }
44+
45+ public function withVariable (string $ id ): void
46+ {
47+ if (!isset (self ::FACTORIES [$ id ])) {
48+ return ;
49+ }
50+
51+ (self ::FACTORIES [$ id ])();
52+ }
53+ }
You can’t perform that action at this time.
0 commit comments