syntax error, unexpected namespaced name “%s”, expecting “function”¶
Description¶
A namespaced name is an identifier with at least one backslash. The body of a class, enumeration, trait or interface does not use any namespaces, as it declares methods, constants and proeprties. There may be namespaced names in a use declaration, but such expression starts with a keyword.
Example¶
<?php
class X {
A\B;
C\D($e);
}
?>
Literal Examples¶
syntax error, unexpected namespaced name “AB”, expecting “function
Solutions¶
Add the
usekeyword before the name to import a trait.Add the
functionkeyword before the name to make it a method, although there should not be any\in the method name.Add the
constkeyword before the name to make it a constant, although there should not be any\in the constant name.Add the
#[keyword before the name to make it an attribute.