prettier / plugin-php

Prettier PHP Plugin

Home Page:https://loilo.github.io/prettier-php-playground/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

prettier cannot deal with class instantiation from a config

snake-py opened this issue · comments

commented

Prettier cannot format the following code:

        $client = new (config('wd.authentication.models.client')(['name' => $data['name']]));

I am getting:

[error] src/Http/Controllers/RegisterController.php: SyntaxError: Parse Error : syntax error, unexpected '(' on line 48
[error]   46 |     protected function create(array $data): BaseUser
[error]   47 |     {
[error] > 48 |         $client = new (config('wd.authentication.models.client')(['name' => $data['name']]));
[error]      |                      ^
[error]   49 |         $client->save();
[error]   50 |
[error]   51 |         $user = $this->getUserObject()::create($this->getNewUserData($data));

WorkAround:

        $ClientModel = config('wd.authentication.models.client');
        $client = new $ClientModel(['name' => $data['name']]);

Looks to more of an upstream parser issue.

Fixed in v0.19.2 🎉