prettier / prettier/plugin-php
Parens incorrectly removed when cloning the result of an expression
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ả
Prettier 2.7.1
PHP Plugin 0.19.1
# Options (if any):
# our .prettierrc
{
"phpVersion": "8.1",
"printWidth": 80,
"tabWidth": 4,
"useTabs": false,
"singleQuote": true,
"trailingCommaPHP": true,
"braceStyle": "psr-2",
"requirePragma": false,
"insertPragma": false
}
Input:
$questions = clone ($panel->primaryViewer()?->questions() ?? new Questions());
Output:
$questions = clone $panel->primaryViewer()?->questions() ?? new Questions();
Expected behavior:
The outermost parens are being removed by prettier, affecting behavior. Given
$questions = clone ($panel->primaryViewer()?->questions() ?? new Questions());
if $panel->primaryViewer() is null, because prettier drops the outermost parens, it ends up leaving PHP to evaluate clone null - something I'm actively guarding against with the null coalesce operator.
I expect the parens to remain in place, resulting in the ?? new Questions() to be cloned.
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 bằng cách tái hiện đầu vào PHP đã được báo cáo và so sánh Prettier 2.7.1 với đầu ra mong đợi. Theo dõi cách formatter xử lý các dấu ngoặc quanh clone expression; công việc được hoàn thành khi các dấu ngoặc bên ngoài vẫn còn, để null-coalesce expression được clone, cùng với một regression test bao phủ trường hợp này.
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
- Lỗi
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức độ hoạt động
- Đình trệ
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức phù hợp với người mới
- 35/100