{"record":{"id":"3ec5847fd69f4395","repo":"nikic/PHP-Parser","slug":"name-must-be-a-string-or-an-instance-of-node-name","errorCode":null,"errorMessage":"Name must be a string or an instance of Node\\Name","messagePattern":"Name must be a string or an instance of Node\\\\Name","errorType":"exception","errorClass":"LogicException","httpStatus":null,"severity":"error","filePath":"lib/PhpParser/BuilderHelpers.php","lineNumber":127,"sourceCode":"        }\n\n        if (is_string($name)) {\n            if (!$name) {\n                throw new \\LogicException('Name cannot be empty');\n            }\n\n            if ($name[0] === '\\\\') {\n                return new Name\\FullyQualified(substr($name, 1));\n            }\n\n            if (0 === strpos($name, 'namespace\\\\')) {\n                return new Name\\Relative(substr($name, strlen('namespace\\\\')));\n            }\n\n            return new Name($name);\n        }\n\n        throw new \\LogicException('Name must be a string or an instance of Node\\Name');\n    }\n\n    /**\n     * Normalizes a name: Converts string names to Name nodes, while also allowing expressions.\n     *\n     * @param Expr|Name|string $name The name to normalize\n     *\n     * @return Name|Expr The normalized name or expression\n     */\n    public static function normalizeNameOrExpr($name) {\n        if ($name instanceof Expr) {\n            return $name;\n        }\n\n        if (!is_string($name) && !($name instanceof Name)) {\n            throw new \\LogicException(\n                'Name must be a string or an instance of Node\\Name or Node\\Expr'\n            );","sourceCodeStart":109,"sourceCodeEnd":145,"githubUrl":"https://github.com/nikic/PHP-Parser/blob/fbd47f7ebcbb450138d92642a0a53b72a5285dda/lib/PhpParser/BuilderHelpers.php#L109-L145","documentation":"Error \"Name must be a string or an instance of Node\\Name\" thrown in nikic/PHP-Parser.","triggerScenarios":"Thrown at lib/PhpParser/BuilderHelpers.php:127 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"}