1
0
mirror of https://github.com/danog/psalm.git synced 2024-11-27 04:45:20 +01:00

Fix issue with array_key_exists not having an effect

This commit is contained in:
Matt Brown 2018-05-24 12:23:50 -04:00
parent c8faaf0ca9
commit 772fd496b7
2 changed files with 12 additions and 1 deletions

View File

@ -112,7 +112,9 @@ class Reconciler
$has_equality = true;
}
$has_isset = $has_isset || $new_type_part_part === 'isset';
$has_isset = $has_isset
|| $new_type_part_part === 'isset'
|| $new_type_part_part === 'array-key-exists';
$result_type_candidate = self::reconcileTypes(
$new_type_part_part,

View File

@ -423,6 +423,15 @@ class RedundantConditionTest extends TestCase
var_export($x);
}',
],
'arrayKeyExistsAccess' => [
'<?php
/** @param array<int, string> $arr */
function foo(array $arr) : void {
if (array_key_exists(1, $arr)) {
$a = ($arr[1] === "b") ? true : false;
}
}',
],
];
}