syntax error, unexpected token “private”, expecting “)”¶
Description¶
private is not expected at this position in the code, as the previous property $a is not finished. It would be finished with a closing parenthesis ), as suggested by the error message, or a comma, to introduce the next property.
This error message might have other variations, such as protected, public, static, readonly, abstract, final.
Example¶
<?php
class ProcessController extends AbstractController
{
public function __construct(
public A $a
private B $b,
) {
}
}
?>
Solutions¶
Add a comma to introduce the next property or argument.
Add a closing parenthesis to close the signature and the previous property.