syntax error, unexpected ‘::’, expecting ‘(’¶
Description¶
This is a situation where a new keyword degrades a previously valid syntax. match
is a new keyword in PHP 8.0, for the eponymous command. It cannot be used as a class name, a function name, or a global constant, as before.
By extension, the match
keyword cannot be used in static object notations, such as calling a constant, or a static method or property.
This error may arise with other keywords, for similar reasons.
Example¶
<?php
echo Match::A;
?>
Solutions¶
Rename the
match
class to a non-keyword name.