{"record":{"id":"060399b645f31885","repo":"phalcon/cphalcon","slug":"the-expression-type-is-unknown","errorCode":null,"errorMessage":"The expression {type} is unknown","messagePattern":"The expression (.+?) is unknown","errorType":"exception","errorClass":"Phalcon\\Annotations\\Exceptions\\UnknownAnnotationExpression","httpStatus":null,"severity":"error","filePath":"phalcon/Annotations/Annotation.zep","lineNumber":156,"sourceCode":"                for item in expr[\"items\"] {\n                    let resolvedItem = this->getExpression(\n                        item[\"expr\"]\n                    );\n\n                    if fetch name, item[\"name\"] {\n                        let arrayValue[name] = resolvedItem;\n                    } else {\n                        let arrayValue[] = resolvedItem;\n                    }\n                }\n\n                return arrayValue;\n\n            case PHANNOT_T_ANNOTATION:\n                return new Annotation(expr);\n\n            default:\n                throw new UnknownAnnotationExpression(type);\n        }\n\n        return value;\n    }\n\n    /**\n     * Returns the annotation's name\n     */\n    public function getName() -> null | string\n    {\n        return this->name;\n    }\n\n    /**\n     * Returns a named argument\n     */\n    public function getNamedArgument( string name) -> var | null\n    {","sourceCodeStart":138,"sourceCodeEnd":174,"githubUrl":"https://github.com/phalcon/cphalcon/blob/b7419de9cd0a8a3f48441ead84c9f8415d463e25/phalcon/Annotations/Annotation.zep#L138-L174","documentation":"While resolving the parameter expression of an annotation, Phalcon walks the parsed token tree; each node must be a recognized type (integer, string, array, nested annotation, etc.). Hitting the default branch means the parser produced a token type the resolver does not know how to turn into a PHP value, so the annotation expression is not representable.","triggerScenarios":"A docblock containing an annotation whose parameter uses unsupported syntax, e.g. `@MyAnnotation(value=@foo bar)` or constructs borrowed from other annotation libraries. Raised while reading annotations via `$annotations->get($class)` / `getMethodAnnotations()` on the affected class.","commonSituations":"Copy-pasting Doctrine-style or JMS-style annotations into a Phalcon project; typos that change token shape (missing quotes, stray characters); upgrading Phalcon across parser token-constant changes.","solutions":["Open the docblock named in the stack trace and rewrite the parameter using supported expressions: literals, quoted strings, arrays `{...}`, and nested `@Annotation(...)`","Quote unusual values: `@Route(prefix='/api')` instead of bare tokens","If you need custom expression types, parse them yourself from the raw annotation arguments rather than inside Phalcon's expression resolver"],"exampleFix":"// before (unsupported token sequence)\n/** @Route(/api/v1/invoices) */\nclass InvoicesController {}\n// after\n/** @Route(prefix='/api/v1/invoices') */\nclass InvoicesController {}","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n    $reflector = $annotations->get($className);\n} catch (\\Phalcon\\Annotations\\Exceptions\\UnknownAnnotationExpression $e) {\n    // log the class so the offending docblock can be fixed; fail soft if annotations are optional\n    $logger->error('Bad annotation expression in ' . $className . ': ' . $e->getMessage());\n    $reflector = null;\n}","preventionTips":["Restrict annotations to the documented expression forms (literals, quoted strings, {...} arrays, nested annotations)","Add a CI step that parses all annotated classes so syntax errors surface before deploy","When copying annotations from other libraries, rewrite them to Phalcon syntax first"],"tags":["annotations","parser","docblock","syntax"],"backgroundTag":"unsupported-expression-type","analyzedSha":"b7419de9cd0a8a3f48441ead84c9f8415d463e25","analyzedAt":"2026-08-21T06:21:18.811Z","schemaVersion":2},"datasetVersion":"2026-08-21T11:28:35.574Z"}