1
0
mirror of https://github.com/danog/psalm.git synced 2024-12-02 09:37:59 +01:00
This commit is contained in:
Daniil Gentili 2022-12-03 18:27:47 +01:00
parent 3437d762af
commit f57d37a7f7
2 changed files with 23 additions and 1 deletions

View File

@ -1140,7 +1140,17 @@ class Reconciler
} else { } else {
$properties = $base_atomic_type->properties; $properties = $base_atomic_type->properties;
$properties[$array_key_offset] = $result_type; $properties[$array_key_offset] = $result_type;
$base_atomic_type = $base_atomic_type->setProperties($properties); if ($base_atomic_type->is_list && !isset($properties[$array_key_offset-1])) {
$base_atomic_type = new TKeyedArray(
$properties,
null,
$base_atomic_type->fallback_params,
false,
$base_atomic_type->from_docblock
);
} else {
$base_atomic_type = $base_atomic_type->setProperties($properties);
}
} }
$new_base_type = $new_base_type->getBuilder()->addType($base_atomic_type)->freeze(); $new_base_type = $new_base_type->getBuilder()->addType($base_atomic_type)->freeze();

View File

@ -891,6 +891,18 @@ class RedundantConditionTest extends TestCase
} }
}' }'
], ],
'countWithNeverValuesInKeyedList' => [
'code' => '<?php
/** @var non-empty-list $report_data */
$report_data = [];
if ( array_key_exists( 2, $report_data ) ) {
} elseif ( !empty( $report_data[0]["type"] ) && rand(0,1) ) {
if ( rand(0,1) ) {}
if ( count( $report_data ) === 1 ) {
}
}'
],
'secondFalsyTwiceWithChange' => [ 'secondFalsyTwiceWithChange' => [
'code' => '<?php 'code' => '<?php
/** /**