Skip to content

Commit db91928

Browse files
phpstan-botstaabm
authored andcommitted
Add regression test for #7978
Closes phpstan/phpstan#7978
1 parent d298bcc commit db91928

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?php declare(strict_types = 1);
2+
3+
namespace Bug7978;
4+
5+
use function PHPStan\Testing\assertType;
6+
7+
class Test {
8+
9+
const FIELD_SETS = [
10+
'basic' => ['username', 'password'],
11+
'headers' => ['app_id', 'app_key'],
12+
];
13+
14+
public function doSomething(): void
15+
{
16+
foreach (self::FIELD_SETS as $type => $fields) {
17+
$credentials = [];
18+
foreach ($fields as $field) {
19+
$credentials[$field] = 'fake';
20+
}
21+
assertType("array{app_id?: 'fake', app_key?: 'fake', password?: 'fake', username?: 'fake'}", $credentials);
22+
}
23+
}
24+
}

0 commit comments

Comments
 (0)