mirror of
https://github.com/danog/psalm.git
synced 2025-01-22 13:51:54 +01:00
key_exists()
is an alias for array_key_exists()
Fixes vimeo/psalm#10346
This commit is contained in:
parent
294220c744
commit
6e2effaf9a
@ -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