-
Notifications
You must be signed in to change notification settings - Fork 426
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix array_unshift for union of constant arrays
- Loading branch information
1 parent
bc31fd3
commit 9077af6
Showing
3 changed files
with
53 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
tests/PHPStan/Analyser/data/constant-array-union-unshift.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<?php | ||
|
||
namespace ConstantArrayUnionUnshift; | ||
|
||
use function PHPStan\Testing\assertType; | ||
|
||
function () { | ||
if (random_int(0, 1)) { | ||
$array = ['a' => 1]; | ||
} else { | ||
$array = ['b' => 1]; | ||
} | ||
|
||
assertType('array{a: 1}|array{b: 1}', $array); | ||
|
||
array_unshift($array, 2); | ||
|
||
assertType('array{0: 2, a: 1}|array{0: 2, b: 1}', $array); | ||
}; |