-
Notifications
You must be signed in to change notification settings - Fork 574
Expand file tree
/
Copy pathbug-13805.php
More file actions
46 lines (37 loc) · 1.08 KB
/
bug-13805.php
File metadata and controls
46 lines (37 loc) · 1.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
<?php // onlyForPhpVersions: 80100
declare(strict_types = 1);
namespace Bug13805;
use function PHPStan\Testing\assertType;
/**
* @phpstan-type MinimalRowDefinition array{foo: string, muh: string}
*/
class HelloWorld
{
/**
* @param array{test?: array<string, mixed>} $defaultItems
* @param MinimalRowDefinition $row
*/
public function sayHello(array $row, array $defaultItems): void
{
$result = [
...($defaultItems['test'] ?? []),
...$row,
];
assertType('non-empty-array<string, mixed>&hasOffsetValue(\'foo\', string)&hasOffsetValue(\'muh\', string)', $result);
// $result will always contain the keys from MinimalRowDefinition, therefore also the needed muh
$this->testStuff($result);
}
/** @param array{muh: string} $data */
private function testStuff($data): void
{
}
/**
* @param array<string, int> $a
* @param array{x: string, y: int} $b
*/
public function testSpreadOrder(array $a, array $b): void
{
$result = [...$a, ...$b];
assertType('non-empty-array<string, int|string>&hasOffsetValue(\'x\', string)&hasOffsetValue(\'y\', int)', $result);
}
}