phalcon/cphalcon · error · Phalcon\Mvc\Model\Exceptions\InvalidGetModelNameReturn
getModelName should return array or string
Error message
getModelName should return array or string
What it means
Thrown while binding model parameters: the value returned by getModelName() on the handler is neither a string (single model class) nor an array (paramKey => class map), so the binder cannot interpret it. Indicates the BindableInterface implementation returns an invalid type such as null, int, or object.
Solutions
- Fix getModelName() to return a class name string or an array of parameter-name => class-name entries
- Add a return type declaration of string|array to getModelName() so mistakes are caught early
- Check that getModelName() does not return null from an unresolved conditional path
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at phalcon/Mvc/Model/Binder.zep:237 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/a82c30e24708e1a9.
Report an issue: GitHub.
Appendix: source
Thrown at phalcon/Mvc/Model/Binder.zep:237
let realClasses = {handlerClass}::getModelName();
} elseif handler instanceof BindableInterface {
let realClasses = handler->getModelName();
} else {
throw new HandlerMustImplementBindable();
}
}
if typeof realClasses == "array" {
if unlikely !fetch className, realClasses[paramKey] {
throw new MissingModelClassName(paramKey);
}
let boundModel = this->findBoundModel(paramValue, className);
} elseif typeof realClasses == "string" {
let className = realClasses;
let boundModel = this->findBoundModel(paramValue, className);
} else {
throw new InvalidGetModelNameReturn();
}
} elseif is_subclass_of(className, Model::class) {
let boundModel = this->findBoundModel(paramValue, className);
}
if boundModel != null {
let this->originalValues[paramKey] = paramValue;
let params[paramKey] = boundModel;
let this->boundModels[paramKey] = boundModel;
let paramsCache[paramKey] = className;
}
}
if cache != null {
cache->set(cacheKey, paramsCache);
}
let this->internalCache[cacheKey] = paramsCache;View on GitHub (pinned to b7419de9cd)