{"record":{"id":"eb765c75e47ce9a8","repo":"nikic/PHP-Parser","slug":"type-must-be-a-string-or-an-instance-of-name-ide","errorCode":null,"errorMessage":"Type must be a string, or an instance of Name, Identifier or ComplexType","messagePattern":"Type must be a string, or an instance of Name, Identifier or ComplexType","errorType":"exception","errorClass":"LogicException","httpStatus":null,"severity":"error","filePath":"lib/PhpParser/BuilderHelpers.php","lineNumber":167,"sourceCode":"    }\n\n    /**\n     * Normalizes a type: Converts plain-text type names into proper AST representation.\n     *\n     * In particular, builtin types become Identifiers, custom types become Names and nullables\n     * are wrapped in NullableType nodes.\n     *\n     * @param string|Name|Identifier|ComplexType $type The type to normalize\n     *\n     * @return Name|Identifier|ComplexType The normalized type\n     */\n    public static function normalizeType($type) {\n        if (!is_string($type)) {\n            if (\n                !$type instanceof Name && !$type instanceof Identifier &&\n                !$type instanceof ComplexType\n            ) {\n                throw new \\LogicException(\n                    'Type must be a string, or an instance of Name, Identifier or ComplexType'\n                );\n            }\n            return $type;\n        }\n\n        $nullable = false;\n        if (strlen($type) > 0 && $type[0] === '?') {\n            $nullable = true;\n            $type = substr($type, 1);\n        }\n\n        $builtinTypes = [\n            'array',\n            'callable',\n            'bool',\n            'int',\n            'float',","sourceCodeStart":149,"sourceCodeEnd":185,"githubUrl":"https://github.com/nikic/PHP-Parser/blob/fbd47f7ebcbb450138d92642a0a53b72a5285dda/lib/PhpParser/BuilderHelpers.php#L149-L185","documentation":"Error \"Type must be a string, or an instance of Name, Identifier or ComplexType\" thrown in nikic/PHP-Parser.","triggerScenarios":"Thrown at lib/PhpParser/BuilderHelpers.php:167 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"}