Skip to content

Commit 83a0511

Browse files
Add non regression test
1 parent 8ae740c commit 83a0511

File tree

2 files changed

+36
-0
lines changed

2 files changed

+36
-0
lines changed

tests/PHPStan/Rules/Functions/CallCallablesRuleTest.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff 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'], [
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
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+
}

0 commit comments

Comments
 (0)