prettier / plugin-php

Prettier PHP Plugin
https://loilo.github.io/prettier-php-playground/
MIT License
1.74k stars 126 forks source link

parentheses bug. #2340

Open dvlpr91 opened 5 months ago

dvlpr91 commented 5 months ago

@prettier/plugin-php v0.22.2 Playground link

Input:

<?php

(require_once __DIR__ . '/../bootstrap/app.php')->handleRequest(Request::capture());

Output:

<?php

require_once __DIR__ . "/../bootstrap/app.php"->handleRequest(
    Request::capture()
);
vinkla commented 5 months ago

I'm here to report this issue too. The syntax is taken from Laravel 11's public/index.php file.

timmylindh commented 5 months ago

Same

antonioribeiro commented 1 month ago

Is there are plan to fix this one?

dvlpr91 commented 1 month ago
// public/index.php

...
// Bootstrap Laravel and handle the request...
$app = require_once __DIR__ . '/../bootstrap/app.php';
$app->handleRequest(Request::capture());
// artisan

...
// Bootstrap Laravel and handle the command...
$app = require_once __DIR__ . '/bootstrap/app.php';
$status = $app->handleCommand(new ArgvInput());
exit($status);
cay89 commented 3 weeks ago

It also removes the parentheses from the nameless class definition in Laravel 11 migrations.

There are parentheses after the class keyword:

return new class () extends Migration {

Run Prettier, and they’re gone:

return new class extends Migration {

The PER Coding Style 2.0 requires parentheses when instantiating a new class: https://www.php-fig.org/per/coding-style/#4-classes-properties-and-methods