{"record":{"id":"0cef742d629923ff","repo":"nikic/PHP-Parser","slug":"doc-comment-must-be-a-string-or-an-instance-of-php","errorCode":null,"errorMessage":"Doc comment must be a string or an instance of PhpParser\\Comment\\Doc","messagePattern":"Doc comment must be a string or an instance of PhpParser\\\\Comment\\\\Doc","errorType":"exception","errorClass":"LogicException","httpStatus":null,"severity":"error","filePath":"lib/PhpParser/BuilderHelpers.php","lineNumber":295,"sourceCode":"    }\n\n    /**\n     * Normalizes a doc comment: Converts plain strings to PhpParser\\Comment\\Doc.\n     *\n     * @param Comment\\Doc|string $docComment The doc comment to normalize\n     *\n     * @return Comment\\Doc The normalized doc comment\n     */\n    public static function normalizeDocComment($docComment): Comment\\Doc {\n        if ($docComment instanceof Comment\\Doc) {\n            return $docComment;\n        }\n\n        if (is_string($docComment)) {\n            return new Comment\\Doc($docComment);\n        }\n\n        throw new \\LogicException('Doc comment must be a string or an instance of PhpParser\\Comment\\Doc');\n    }\n\n    /**\n     * Normalizes a attribute: Converts attribute to the Attribute Group if needed.\n     *\n     * @param Node\\Attribute|Node\\AttributeGroup $attribute\n     *\n     * @return Node\\AttributeGroup The Attribute Group\n     */\n    public static function normalizeAttribute($attribute): Node\\AttributeGroup {\n        if ($attribute instanceof Node\\AttributeGroup) {\n            return $attribute;\n        }\n\n        if (!($attribute instanceof Node\\Attribute)) {\n            throw new \\LogicException('Attribute must be an instance of PhpParser\\Node\\Attribute or PhpParser\\Node\\AttributeGroup');\n        }\n","sourceCodeStart":277,"sourceCodeEnd":313,"githubUrl":"https://github.com/nikic/PHP-Parser/blob/fbd47f7ebcbb450138d92642a0a53b72a5285dda/lib/PhpParser/BuilderHelpers.php#L277-L313","documentation":"Error \"Doc comment must be a string or an instance of PhpParser\\Comment\\Doc\" thrown in nikic/PHP-Parser.","triggerScenarios":"Thrown at lib/PhpParser/BuilderHelpers.php:295 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"fbd47f7ebcbb450138d92642a0a53b72a5285dda","analyzedAt":"2026-08-17T03:58:32.123Z","schemaVersion":2},"datasetVersion":"2026-08-17T04:17:16.089Z"}