{"record":{"id":"4e7969f6f71953ba","repo":"yiisoft/yii2","slug":"second-parameter-array-cannot-be-arrayaccess-in","errorCode":null,"errorMessage":"Second parameter($array) cannot be ArrayAccess in case insensitive mode","messagePattern":"Second parameter\\(\\$array\\) cannot be ArrayAccess in case insensitive mode","errorType":"exception","errorClass":"InvalidArgumentException","httpStatus":null,"severity":"error","filePath":"framework/helpers/BaseArrayHelper.php","lineNumber":640,"sourceCode":"     * @return bool whether the array contains the specified key\n     */\n    public static function keyExists($key, $array, $caseSensitive = true)\n    {\n        // ToDo: This check can be removed when the minimum PHP version is >= 8.1 (Yii2.2)\n        if (is_float($key)) {\n            $key = (int)$key;\n        }\n\n        if ($caseSensitive) {\n            if (is_array($array) && array_key_exists($key, $array)) {\n                return true;\n            }\n            // Cannot use `array_has_key` on Objects for PHP 7.4+, therefore we need to check using [[ArrayAccess::offsetExists()]]\n            return $array instanceof ArrayAccess && $array->offsetExists($key);\n        }\n\n        if ($array instanceof ArrayAccess) {\n            throw new InvalidArgumentException('Second parameter($array) cannot be ArrayAccess in case insensitive mode');\n        }\n\n        foreach (array_keys($array) as $k) {\n            if (strcasecmp($key, $k) === 0) {\n                return true;\n            }\n        }\n\n        return false;\n    }\n\n    /**\n     * Sorts an array of objects or arrays (with the same structure) by one or several keys.\n     * @param array $array the array to be sorted. The array will be modified after calling this method.\n     * @param string|\\Closure|array $key the key(s) to be sorted by. This refers to a key name of the sub-array\n     * elements, a property name of the objects, or an anonymous function returning the values for comparison\n     * purpose. The anonymous function signature should be: `function($item)`.\n     * To sort by multiple keys, provide an array of keys here.","sourceCodeStart":622,"sourceCodeEnd":658,"githubUrl":"https://github.com/yiisoft/yii2/blob/66f00d18a29b520f85e8e8f1e32d1e7e7b556cac/framework/helpers/BaseArrayHelper.php#L622-L658","documentation":"Error \"Second parameter($array) cannot be ArrayAccess in case insensitive mode\" thrown in yiisoft/yii2.","triggerScenarios":"Thrown at framework/helpers/BaseArrayHelper.php:640 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"66f00d18a29b520f85e8e8f1e32d1e7e7b556cac","analyzedAt":"2026-08-17T05:17:23.470Z","schemaVersion":2},"datasetVersion":"2026-08-17T09:17:11.063Z"}