{"record":{"id":"e9604014201ce62f","repo":"phalcon/cphalcon","slug":"alias-name-must-be-a-string","errorCode":null,"errorMessage":"Alias name must be a string","messagePattern":"Alias name must be a string","errorType":"exception","errorClass":"Phalcon\\Di\\Exceptions\\AliasNameMustBeString","httpStatus":null,"severity":"error","filePath":"phalcon/Di/Di.zep","lineNumber":670,"sourceCode":"     * @throws Exception\n     */\n    public function setAlias(string name, var aliases) -> <self>\n    {\n        var alias, currentAliases, localAliases;\n\n        if (true !== this->has(name)) {\n            throw Exception::serviceNotFound(name);\n        }\n\n        let currentAliases = this->aliases;\n        let localAliases   = aliases;\n        if (typeof localAliases !== \"array\") {\n            let localAliases = [localAliases];\n        }\n\n        for alias in localAliases {\n            if (typeof alias !== \"string\") {\n                throw new AliasNameMustBeString();\n            }\n\n            if (true === isset(currentAliases[alias]) || true === this->has(alias)) {\n                throw new AliasAlreadyInUse(alias);\n            }\n\n            let currentAliases[alias] = name;\n        }\n\n        let this->aliases = currentAliases;\n\n        return this;\n    }\n\n    /**\n     * Set a default dependency injection container to be obtained into static\n     * methods\n     */","sourceCodeStart":652,"sourceCodeEnd":688,"githubUrl":"https://github.com/phalcon/cphalcon/blob/b7419de9cd0a8a3f48441ead84c9f8415d463e25/phalcon/Di/Di.zep#L652-L688","documentation":"Thrown by Di::setAlias when an entry in the aliases argument is not a string. Aliases are stored as string keys in the internal alias map, so any non-string element (int, object, array) is rejected before being registered. Pass a string or an array of strings.","triggerScenarios":"Thrown at phalcon/Di/Di.zep:670 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Pass only strings (or an array of strings) as the alias parameter","Remove null/integer entries from the aliases list before calling setAlias"],"exampleFix":null,"handlingStrategy":"type-guard","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"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"}