key_exists/fnKeyExists

Affected version
2.1.10 Patch 2

Xon

Well-known member
fnKeyExists calls array_key_exists without checking if $array is an actual array.

According to https://www.php.net/manual/en/function.array-key-exists.php property_exists should be used if $array is an object. And some additional work is probably required if __get or ArrayObject support is desired.

I'm fairly sure this function should return false if the $array argument is neither an array or an object. Or generate an error.
 
Last edited:

Zenexer

Active member
While we're at it, array_key_exists has its own opcode as of PHP 7.4, but it only works in namespaced files if the fully-qualified name is used (\array_key_exists) or the function is imported (use function array_key_exists). Probably couldn't hurt to get into the habit of replacing array_key_exists with \array_key_exists in new or modified code that's likely to get called a lot.
 

021

Well-known member
but it only works in namespaced files if the fully-qualified name is used (\array_key_exists) or the function is imported (use function array_key_exists
.where did you find this information? Can't find anything about it
 

Zenexer

Active member
Top