{"record":{"id":"53295bfca3ad01f9","repo":"phalcon/cphalcon","slug":"columnmap-not-returned-an-array","errorCode":null,"errorMessage":"columnMap() not returned an array","messagePattern":"columnMap\\(\\) not returned an array","errorType":"exception","errorClass":"Phalcon\\Mvc\\Model\\MetaData\\Exceptions\\ColumnMapNotArray","httpStatus":null,"severity":"error","filePath":"phalcon/Mvc/Model/MetaData/Strategy/Introspection.zep","lineNumber":43,"sourceCode":"{\n    /**\n     * Read the model's column map, this can't be inferred\n     */\n    final public function getColumnMaps(<ModelInterface> model, <DiInterface> container) -> array\n    {\n        var orderedColumnMap, userColumnMap, reversedColumnMap, name, userName;\n\n        let orderedColumnMap = null;\n        let reversedColumnMap = null;\n\n        /**\n         * Check for a columnMap() method on the model\n         */\n        if method_exists(model, \"columnMap\") {\n            let userColumnMap = model->{\"columnMap\"}();\n\n            if unlikely typeof userColumnMap != \"array\" {\n                throw new ColumnMapNotArray();\n            }\n\n            let reversedColumnMap = [],\n                orderedColumnMap = userColumnMap;\n\n            for name, userName in userColumnMap {\n                let reversedColumnMap[userName] = name;\n            }\n        }\n\n        /**\n         * Store the column map\n         */\n        return [orderedColumnMap, reversedColumnMap];\n    }\n\n    /**\n     * The meta-data is obtained by reading the column descriptions from the database information schema","sourceCodeStart":25,"sourceCodeEnd":61,"githubUrl":"https://github.com/phalcon/cphalcon/blob/b7419de9cd0a8a3f48441ead84c9f8415d463e25/phalcon/Mvc/Model/MetaData/Strategy/Introspection.zep#L25-L61","documentation":"Fires in Introspection::getColumnMaps() when the model defines a columnMap() method but calling it returns a non-array value. The guard protects the meta-data introspection strategy from a misimplemented model method; the faulty input is the developer-supplied columnMap() implementation on the model class.","triggerScenarios":"Thrown at phalcon/Mvc/Model/MetaData/Strategy/Introspection.zep:43 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Fix the model's columnMap() so it returns an associative array mapping attribute names to column names","Ensure no early return/null is possible inside columnMap()","Verify the method has no conditions that return a non-array value"],"exampleFix":"public function columnMap() { return ['id' => 'id', 'theName' => 'name']; }","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always return an array literal from columnMap(), even when empty","Unit-test the column map on every model that defines one"],"tags":[],"backgroundTag":null,"analyzedSha":"b7419de9cd0a8a3f48441ead84c9f8415d463e25","analyzedAt":"2026-08-21T06:21:18.811Z","contentChangedAt":"2026-08-21T06:21:18.811Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}