prettier / prettier/plugin-php
Allow attributes to be placed above constructor properties
Chưa có ai nhận issue này.
- 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
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,
) {
}
}
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.
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.
Đánh giá
- Công nghệ
- php
- Lĩnh vực
- tooling
- Loại issue
- Tính năng
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức độ hoạt động
- Đình trệ
- Độ rõ ràng
- Khá rõ ràng
- Mức phù hợp với người mới
- 42/100