yiisoft/yii2 · error · InvalidArgumentException
Second parameter($array) cannot be ArrayAccess in case insen
Error message
Second parameter($array) cannot be ArrayAccess in case insensitive mode
What it means
Error "Second parameter($array) cannot be ArrayAccess in case insensitive mode" thrown in yiisoft/yii2.
Source
Thrown at framework/helpers/BaseArrayHelper.php:640
* @return bool whether the array contains the specified key
*/
public static function keyExists($key, $array, $caseSensitive = true)
{
// ToDo: This check can be removed when the minimum PHP version is >= 8.1 (Yii2.2)
if (is_float($key)) {
$key = (int)$key;
}
if ($caseSensitive) {
if (is_array($array) && array_key_exists($key, $array)) {
return true;
}
// Cannot use `array_has_key` on Objects for PHP 7.4+, therefore we need to check using [[ArrayAccess::offsetExists()]]
return $array instanceof ArrayAccess && $array->offsetExists($key);
}
if ($array instanceof ArrayAccess) {
throw new InvalidArgumentException('Second parameter($array) cannot be ArrayAccess in case insensitive mode');
}
foreach (array_keys($array) as $k) {
if (strcasecmp($key, $k) === 0) {
return true;
}
}
return false;
}
/**
* Sorts an array of objects or arrays (with the same structure) by one or several keys.
* @param array $array the array to be sorted. The array will be modified after calling this method.
* @param string|\Closure|array $key the key(s) to be sorted by. This refers to a key name of the sub-array
* elements, a property name of the objects, or an anonymous function returning the values for comparison
* purpose. The anonymous function signature should be: `function($item)`.
* To sort by multiple keys, provide an array of keys here.View on GitHub (pinned to 66f00d18a2)
When it happens
Trigger: Thrown at framework/helpers/BaseArrayHelper.php:640 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of yiisoft/yii2@66f00d18a2 (2026-08-17).
Data as JSON: /api/errors/4e7969f6f71953ba.
Report an issue: GitHub.