Skip to content

Commit b4b44cf

Browse files
vokuondrejmirtes
authored andcommitted
Add more tests for "array_merge"
1 parent f21b218 commit b4b44cf

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

tests/PHPStan/Analyser/data/array-merge.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,21 @@
77
class Foo
88
{
99

10+
private const DEFAULT_SETTINGS = [
11+
'remove' => 'first',
12+
'limit' => PHP_INT_MAX,
13+
];
14+
15+
/**
16+
* @param array<string, float|null> $settings
17+
*/
18+
public function arrayMergeWithConst(array $settings): void
19+
{
20+
$settings = array_merge(self::DEFAULT_SETTINGS, $settings);
21+
22+
assertType("array<string, 9223372036854775807|'first'|float|null>&nonEmpty", $settings);
23+
}
24+
1025
/**
1126
* @param array{foo: '1', bar: '2', lall: '3', 2: '2', 3: '3'} $array1
1227
* @param array{foo: '1', bar: '4', lall2: '3', 2: '4', 3: '6'} $array2
@@ -32,6 +47,8 @@ public function arrayMergeSimple($array1, $array2): void
3247
assertType("array<int>", array_merge($array1, $array1));
3348
assertType("array<int|string>", array_merge($array1, $array2));
3449
assertType("array<int|string>", array_merge($array2, $array1));
50+
51+
assertType("array('foo' => '')", array_merge(['foo' => ''])); // issue #2567
3552
}
3653

3754
/**

0 commit comments

Comments
 (0)