syntax error, unexpected identifier “%s”, expecting “;” or “{”¶
Description¶
An abstract method’s signature must be terminated with a semicolon, since it has no body, and a concrete method’s signature must be followed by a { opening the body. Here, an extra identifier was found right after the closing parenthesis of the argument list, where PHP expected one of those two terminators.
This typically happens when a return type declaration is missing its leading colon, or when a stray word was left over after editing the signature.
Example¶
<?php
abstract class X {
abstract function foo() bar;
}
?>
Literal Examples¶
syntax error, unexpected identifier “bar”, expecting “;” or “{”
Solutions¶
If a return type was intended, add a colon before it:
abstract function foo(): bar;.Remove the extra identifier.
If the method should have a body, replace the identifier with
{and the method’s code.
Changed Behavior¶
This error may appear following an evolution in behavior, in previous versions. See ` <https://php-changed-behaviors.readthedocs.io/en/latest/behavior/.html>`_.