syntax error, unexpected token “class”, expecting-“]”

Description

The previous attribute was not closed with a square bracket, and its syntax is spilling over the supporting class.

Example

<?php

#[Attribute()
class X {}

?>

Solutions

  • Remove the attribute.

  • Close the attribute with a square bracket.