phalcon/cphalcon · error · Phalcon\Mvc\Model\MetaData\Exceptions\ColumnMapNotArray

columnMap() not returned an array

Error message

columnMap() not returned an array

What it means

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.

Solutions

  1. Fix the model's columnMap() so it returns an associative array mapping attribute names to column names
  2. Ensure no early return/null is possible inside columnMap()
  3. Verify the method has no conditions that return a non-array value

Example fix

public function columnMap() { return ['id' => 'id', 'theName' => 'name']; }
Defensive patterns

Strategy: try-catch

Prevention

When it happens

Trigger: Thrown at phalcon/Mvc/Model/MetaData/Strategy/Introspection.zep:43 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of phalcon/cphalcon@b7419de9cd (2026-08-21). Data as JSON: /api/errors/53295bfca3ad01f9. Report an issue: GitHub.

Appendix: source

Thrown at phalcon/Mvc/Model/MetaData/Strategy/Introspection.zep:43

{
    /**
     * Read the model's column map, this can't be inferred
     */
    final public function getColumnMaps(<ModelInterface> model, <DiInterface> container) -> array
    {
        var orderedColumnMap, userColumnMap, reversedColumnMap, name, userName;

        let orderedColumnMap = null;
        let reversedColumnMap = null;

        /**
         * Check for a columnMap() method on the model
         */
        if method_exists(model, "columnMap") {
            let userColumnMap = model->{"columnMap"}();

            if unlikely typeof userColumnMap != "array" {
                throw new ColumnMapNotArray();
            }

            let reversedColumnMap = [],
                orderedColumnMap = userColumnMap;

            for name, userName in userColumnMap {
                let reversedColumnMap[userName] = name;
            }
        }

        /**
         * Store the column map
         */
        return [orderedColumnMap, reversedColumnMap];
    }

    /**
     * The meta-data is obtained by reading the column descriptions from the database information schema

View on GitHub (pinned to b7419de9cd)