nikic/PHP-Parser · error · LogicException
Type must be a string, or an instance of Name, Identifier or
Error message
Type must be a string, or an instance of Name, Identifier or ComplexType
What it means
Error "Type must be a string, or an instance of Name, Identifier or ComplexType" thrown in nikic/PHP-Parser.
Source
Thrown at lib/PhpParser/BuilderHelpers.php:167
}
/**
* Normalizes a type: Converts plain-text type names into proper AST representation.
*
* In particular, builtin types become Identifiers, custom types become Names and nullables
* are wrapped in NullableType nodes.
*
* @param string|Name|Identifier|ComplexType $type The type to normalize
*
* @return Name|Identifier|ComplexType The normalized type
*/
public static function normalizeType($type) {
if (!is_string($type)) {
if (
!$type instanceof Name && !$type instanceof Identifier &&
!$type instanceof ComplexType
) {
throw new \LogicException(
'Type must be a string, or an instance of Name, Identifier or ComplexType'
);
}
return $type;
}
$nullable = false;
if (strlen($type) > 0 && $type[0] === '?') {
$nullable = true;
$type = substr($type, 1);
}
$builtinTypes = [
'array',
'callable',
'bool',
'int',
'float',View on GitHub (pinned to fbd47f7ebc)
When it happens
Trigger: Thrown at lib/PhpParser/BuilderHelpers.php:167 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of nikic/PHP-Parser@fbd47f7ebc (2026-08-17).
Data as JSON: /api/errors/eb765c75e47ce9a8.
Report an issue: GitHub.