syntax error, unexpected token “,”, expecting “)”

Description

The new call was not properly closed with a closing parenthesis, and PHP found a closing square bracket, instead.

Example

<?php

#[A(new X( a: 'b',    ]
class X {}

?>

Solutions

  • Add a closing parenthesis after the comma.

  • Remove the comma, and add a closing parenthesis.