prettier / prettier/plugin-php
Splitting of long lines with closures and imported use variables
まだ誰も着手していません。
- 主要言語
- PHP
- スター
- 1.9k
- フォーク
- 139
- PR マージ指標
- 30日以内にマージされた PR はありません
説明
The way closure imports ("use" variables) are split when a line is too long is not ideal. I'm wondering if there is a way the priority can be changed so that it prefers to keep use variables together with the function arguments?
@prettier/plugin-php v0.16.1
Playground link
Input:
<?php
function test()
{
expectNotification(VerifyEmail::class)->toBeSentTo(
$user,
function ($notification, $channels, $notifiable) use ($user, &$actionUrl) {
$actionUrl = $notification->toMail($user)->actionUrl;
return $channels === ['mail'] && $notifiable->is($user);
},
);
}
Output:
<?php
function test()
{
expectNotification(VerifyEmail::class)->toBeSentTo($user, function ($notification, $channels, $notifiable) use (
$user,
&$actionUrl
) {
$actionUrl = $notification->toMail($user)->actionUrl;
return $channels === ['mail'] && $notifiable->is($user);
});
}
Of course Javascript doesn't have an equivalent of "use" imports, but I tried to approximate it below, and Prettier does what I would expect/prefer.
Prettier 2.2.1
Playground link
--parser babel
--print-width 120
--single-quote
--tab-width 4
--trailing-comma all
Input:
function test()
{
expectNotification(VerifyEmail.name).toBeSentTo(
$user,
function ($notification, $channels, $notifiable, use, $user, A$actionUrl) {
$actionUrl = $notification.toMail($user).actionUrl;
return $channels === ['mail'] && $notifiable.is($user);
},
);
}
Output:
function test() {
expectNotification(VerifyEmail.name).toBeSentTo(
$user,
function ($notification, $channels, $notifiable, use, $user, A$actionUrl) {
$actionUrl = $notification.toMail($user).actionUrl;
return $channels === ['mail'] && $notifiable.is($user);
},
);
}
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
この issue にはソースファイルやテストの記載がありません。まず、リンクされた plugin playground で提供された PHP 入力を再現し、次に closure パラメーターと use 変数を処理する formatter ロジックを見つけてください。整形後の出力で、推奨レイアウトにおいて use 変数が関数の引数とともに維持されれば完了です。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- php
- 領域
- tooling
- issue の種類
- 機能追加
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 45/100