syntax error, unexpected token “private”, expecting “(”

Description

The opening parenthesis that follows a method name is missing. It would be followed by a promoted property declaration, which starts with private.

The same error may apply with the other PHP visibilities, or property options, such as static or readonly.

Example

<?php

class X
{
    public function __construct
        private Y $y,
    ) {
    }
}

?>

Solutions

  • Add the missing opening parenthesis.