Splitting of long lines with closures and imported use variables
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 45/100
Hướng nghiên cứu
Issue không nêu tệp mã nguồn hoặc kiểm thử nào. Hãy bắt đầu bằng cách tái hiện đầu vào PHP được cung cấp trong plugin playground được liên kết, sau đó tìm logic formatter cho các tham số closure và các biến use; hoàn tất có nghĩa là đầu ra được định dạng giữ các biến use cùng với các đối số hàm trong bố cục ưu tiên.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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);
},
);
}
- Ngôn ngữ chính
- PHP
- Star
- 1.9k
- Fork
- 139
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của prettier/plugin-php
-
PHP 8.3 not allowed in options? Đang mở
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 62/100
prettier/plugin-php#2416 · 2 bình luận · 6 reaction ·
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 64/100
prettier/plugin-php#2498 ·
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 55/100
prettier/plugin-php#2495 ·
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 55/100
prettier/plugin-php#2494 · 1 bình luận ·
-
strange format issue Đang mở
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 48/100
prettier/plugin-php#2490 ·
Tất cả issue của prettier/plugin-php
Issue tương tự
-
tooling
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
-
UX
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
ProfessionalWiki/NeoWiki#1525 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 90/100
OpenConext/OpenConext-engineblock#2122 ·
-
Bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
Automattic/safe-publish#594 ·