plugin-php icon indicating copy to clipboard operation
plugin-php copied to clipboard

parentheses bug.

Open dvlpr91 opened this issue 1 year ago • 5 comments

@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()
);

dvlpr91 avatar Mar 13 '24 06:03 dvlpr91

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

vinkla avatar Mar 14 '24 07:03 vinkla

Same

timmylindh avatar Mar 27 '24 14:03 timmylindh

Is there are plan to fix this one?

antonioribeiro avatar Jul 29 '24 13:07 antonioribeiro

// 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);

dvlpr91 avatar Aug 05 '24 08:08 dvlpr91

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

cay89 avatar Aug 15 '24 11:08 cay89