Allow attributes to be placed above constructor properties
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
- 42/100
Hướng nghiên cứu
Bắt đầu với ví dụ playground được liên kết và so sánh đầu vào với đầu ra để hiểu các thuộc tính của constructor-property hiện được định dạng như thế nào. Thay đổi được hoàn tất khi các thuộc tính giữ nguyên vị trí ban đầu bất cứ khi nào mã kết quả vừa với độ rộng in, đồng thời các thuộc tính quá lớn vẫn được định dạng phù hợp.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Currently, attributes used on constructor properties are forcefully placed inline with the property (or above if it doesn't fit the print width).
This can result in chaotic code where the types and names of the properties are all over the place, making it much harder to scan.
I feel like it would be better to allow the attributes to retain their original placement, as long as everything fits within the print width.
Here's an example of this happening:
@prettier/plugin-php v0.22.2
Playground link
Input:
<?php
class VariantData extends Data
{
public function __construct(
#[Exists(Variant::class, 'id')]
public int|Optional $id,
public int|null $media_id,
#[RequiredWithout('id'), Filled, StringType, Max(255)]
public string $title,
#[RequiredWithout('id'), Numeric, Min(0)]
public string $price,
#[Numeric, Min(0)]
public string|null $compare_at_price,
#[Min(0)]
public int $min_stock,
) {
}
}
Output:
<?php
class VariantData extends Data
{
public function __construct(
#[Exists(Variant::class, 'id')] public int|Optional $id,
public int|null $media_id,
#[
RequiredWithout('id'),
Filled,
StringType,
Max(255),
]
public string $title,
#[RequiredWithout('id'), Numeric, Min(0)] public string $price,
#[Numeric, Min(0)] public string|null $compare_at_price,
#[Min(0)] public int $min_stock,
) {
}
}
- 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ự
-
sync-en
Độ khó 1/5 1-3 giờ Mức phù hợp với người mới 85/100
-
sync-en
Độ khó 1/5 1-3 giờ Mức phù hợp với người mới 85/100
-
Перевод устарел
Độ khó 1/5 1-3 giờ Mức phù hợp với người mới 78/100
-
[6.x]: "Cannot use object of type stdClass as array" loading Users index (regression of #19182) Đang mở
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 90/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 85/100