Skip to content

Commit

Permalink
Merge pull request #9903 from ygottschalk/fix/9827-union-empty-array-…
Browse files Browse the repository at this point in the history
…and-false

Fixes #9827
  • Loading branch information
orklah committed Jun 15, 2023
2 parents 70795bc + d11bb90 commit eb64a47
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/Psalm/Internal/Type/TypeCombiner.php
Expand Up @@ -130,7 +130,9 @@ public static function combine(
if (count($combination->value_types) === 1
&& !count($combination->objectlike_entries)
&& (!$combination->array_type_params
|| $combination->array_type_params[1]->isNever()
|| ( $overwrite_empty_array
&& $combination->array_type_params[1]->isNever()
)
)
&& !$combination->builtin_type_params
&& !$combination->object_type_params
Expand Down
22 changes: 22 additions & 0 deletions tests/TypeCombinationTest.php
Expand Up @@ -338,6 +338,28 @@ public function providerTestValidTypeCombination(): array
'ArrayObject<int, string>',
],
],
'emptyArrayAndFalse' => [
'array<never, never>|false',
[
'array<never, never>',
'false',
],
],
'emptyArrayAndTrue' => [
'array<never, never>|true',
[
'array<never, never>',
'true',
],
],
'emptyArrayWithTrueAndFalse' => [
'array<never, never>|bool',
[
'array<never, never>',
'true',
'false',
],
],
'falseDestruction' => [
'bool',
[
Expand Down

0 comments on commit eb64a47

Please sign in to comment.