Skip to content

Commit

Permalink
don't stop analyzing array, even if we already have a type and we can…
Browse files Browse the repository at this point in the history
…'t create an object like
  • Loading branch information
orklah committed Dec 7, 2021
1 parent 4a35a85 commit c17af41
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 4 deletions.
Expand Up @@ -453,10 +453,6 @@ private static function analyzeArrayItem(
}
}

if ($array_creation_info->item_value_atomic_types && !$array_creation_info->can_create_objectlike) {
return;
}

if ($item_value_type = $statements_analyzer->node_data->getType($item->value)) {
if ($item_key_value !== null && count($array_creation_info->property_types) <= 100) {
$array_creation_info->property_types[$item_key_value] = $item_value_type;
Expand Down
22 changes: 22 additions & 0 deletions tests/ArrayAssignmentTest.php
Expand Up @@ -1693,6 +1693,28 @@ function unpackArray(array $data): array
[],
'8.1'
],
'unpackArrayWithTwoTypesNotObjectLike' => [
'<?php
function int(): int
{
return 0;
}
/**
* @return list<positive-int>
*/
function posiviteIntegers(): array
{
return [1];
}
$_a = [...posiviteIntegers(), int()];',
'assertions' => [
'$_a' => 'non-empty-list<int>',
],
[],
'8.1'
],
];
}

Expand Down

0 comments on commit c17af41

Please sign in to comment.