mirror of
https://github.com/danog/psalm.git
synced 2025-01-22 05:41:20 +01:00
Merge pull request #10598 from weirdan/key_exists-is-an-alias-for-array_key_exists
This commit is contained in:
commit
f045730927
@ -2055,7 +2055,9 @@ final class AssertionFinder
|
||||
|
||||
protected static function hasArrayKeyExistsCheck(PhpParser\Node\Expr\FuncCall $stmt): bool
|
||||
{
|
||||
return $stmt->name instanceof PhpParser\Node\Name && strtolower($stmt->name->getFirst()) === 'array_key_exists';
|
||||
return $stmt->name instanceof PhpParser\Node\Name
|
||||
&& (strtolower($stmt->name->getFirst()) === 'array_key_exists'
|
||||
|| strtolower($stmt->name->getFirst()) === 'key_exists');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -507,6 +507,19 @@ class ArrayKeyExistsTest extends TestCase
|
||||
'ignored_issues' => [],
|
||||
'php_version' => '8.0',
|
||||
],
|
||||
'keyExistsAsAliasForArrayKeyExists' => [
|
||||
'code' => <<<'PHP'
|
||||
<?php
|
||||
/**
|
||||
* @param array<string, string> $arr
|
||||
*/
|
||||
function foo(array $arr): void {
|
||||
if (key_exists("a", $arr)) {
|
||||
echo $arr["a"];
|
||||
}
|
||||
}
|
||||
PHP,
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user