Skip to content

Commit

Permalink
Add more tests for "array_merge"
Browse files Browse the repository at this point in the history
  • Loading branch information
voku authored and ondrejmirtes committed Aug 25, 2021
1 parent f21b218 commit b4b44cf
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions tests/PHPStan/Analyser/data/array-merge.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,21 @@
class Foo
{

private const DEFAULT_SETTINGS = [
'remove' => 'first',
'limit' => PHP_INT_MAX,
];

/**
* @param array<string, float|null> $settings
*/
public function arrayMergeWithConst(array $settings): void
{
$settings = array_merge(self::DEFAULT_SETTINGS, $settings);

assertType("array<string, 9223372036854775807|'first'|float|null>&nonEmpty", $settings);
}

/**
* @param array{foo: '1', bar: '2', lall: '3', 2: '2', 3: '3'} $array1
* @param array{foo: '1', bar: '4', lall2: '3', 2: '4', 3: '6'} $array2
Expand All @@ -32,6 +47,8 @@ public function arrayMergeSimple($array1, $array2): void
assertType("array<int>", array_merge($array1, $array1));
assertType("array<int|string>", array_merge($array1, $array2));
assertType("array<int|string>", array_merge($array2, $array1));

assertType("array('foo' => '')", array_merge(['foo' => ''])); // issue #2567
}

/**
Expand Down

0 comments on commit b4b44cf

Please sign in to comment.