mirror of
https://github.com/danog/psalm.git
synced 2024-11-30 04:39:00 +01:00
Fix strict isset reconciliation
This commit is contained in:
parent
6460d907f9
commit
2299cecd23
@ -782,7 +782,7 @@ class Reconciler
|
||||
);
|
||||
}
|
||||
|
||||
if ($new_var_type === 'isset' || $new_var_type === 'array-key-exists') {
|
||||
if (!$is_strict_equality && ($new_var_type === 'isset' || $new_var_type === 'array-key-exists')) {
|
||||
return Type::getNull();
|
||||
}
|
||||
|
||||
|
@ -326,6 +326,46 @@ class TypeAlgebraTest extends TestCase
|
||||
}
|
||||
}',
|
||||
],
|
||||
'moreConvolutedArrayCreation' => [
|
||||
'<?php
|
||||
function fetchRow() : array {
|
||||
return ["c" => "UK"];
|
||||
}
|
||||
|
||||
$arr = [];
|
||||
|
||||
foreach ([1, 2, 3] as $i) {
|
||||
$row = fetchRow();
|
||||
|
||||
if (!isset($arr[$row["c"]])) {
|
||||
$arr[$row["c"]] = 0;
|
||||
}
|
||||
|
||||
$arr[$row["c"]] = 1;
|
||||
}',
|
||||
'assertions' => [],
|
||||
'error_levels' => ['MixedArrayOffset'],
|
||||
],
|
||||
'moreConvolutedNestedArrayCreation' => [
|
||||
'<?php
|
||||
function fetchRow() : array {
|
||||
return ["c" => "UK"];
|
||||
}
|
||||
|
||||
$arr = [];
|
||||
|
||||
foreach ([1, 2, 3] as $i) {
|
||||
$row = fetchRow();
|
||||
|
||||
if (!isset($arr[$row["c"]]["foo"])) {
|
||||
$arr[$row["c"]]["foo"] = 0;
|
||||
}
|
||||
|
||||
$arr[$row["c"]]["foo"] = 1;
|
||||
}',
|
||||
'assertions' => [],
|
||||
'error_levels' => ['MixedArrayOffset'],
|
||||
],
|
||||
'noParadoxInLoop' => [
|
||||
'<?php
|
||||
function paradox2(): void {
|
||||
|
Loading…
Reference in New Issue
Block a user