SYNTAX ERROR PROBLEM INSIDE OOP PHP
My problem is:
syntax error, unexpected 'private' (T_PRIVATE), expecting variable (T_VARIABLE)
When I do this:
public function __construct(private ProductGateway $gateway)
{
}
and call $getway there:
private function processCollectionRequest(string $method): void
{
switch($method) {
case "GET":
echo json_encode($this->gateway->getAll());
break;
}
}
I got this error: syntax error, unexpected 'private' (T_PRIVATE), expecting variable (T_VARIABLE)
syntax error, unexpected 'private' (T_PRIVATE), expecting variable (T_VARIABLE)
When I do this:
public function __construct(private ProductGateway $gateway)
{
}
and call $getway there:
private function processCollectionRequest(string $method): void
{
switch($method) {
case "GET":
echo json_encode($this->gateway->getAll());
break;
}
}
I got this error: syntax error, unexpected 'private' (T_PRIVATE), expecting variable (T_VARIABLE)
