Illegal function name
Description
This error messages appears when there is an attempt to create a closure from a function, whose name is not a valid function. Numbers, such as float and integers, are not valid function name, and yield this error. Negative numbers, and other types yield a distinct error.
Example
<?php
const Closure = (0)(...);
var_dump(Closure);
?>
Alternatives
- Use a string, instead of a number. Check that the string is a valid name for a function or a static method.
- Ensures that the name is a static expression, and that each element may be resolved at compile time.
Related error messages
- cannot-use-dynamic-function-name-in-constant-expression
- illegal-method-name
- cannot-use-dynamic-method-name-in-constant-expression
Changed Behavior
This error may appear following an evolution in behavior, in previous versions. See