Unstable runs: comment in php tag mixed with html
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 38/100
Hướng nghiên cứu
Tái hiện ba ví dụ bằng Prettier 3.5.3 và PHP Plugin 0.22.4, bắt đầu với các comment ngay sau thẻ PHP. Theo dõi đường đi của formatter khi xử lý PHP và HTML trộn lẫn, sau đó thêm phạm vi kiểm thử hồi quy cho các ví dụ; hoàn thành có nghĩa là việc format lặp lại tạo ra đầu ra giống hệt nhau và không có dòng comment nào bị nhân đôi hoặc di chuyển.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
When prettier-php has a comment directly after <php, it reformats the comment on each successive run, resulting in strange behaviour. The most bizarre is copying the line on each successive run of prettier.
note: By stable, I mean the second time you run prettier, it doesn't change the files. If there's a better word for this, I'm happy to change my description.
This bug is captured in a comment on another issue. However, due to this bug breaking a core properties of prettier, stable transformations, I think it's worth its own issue.
similar bugs:
- https://github.com/prettier/plugin-php/issues/2419 - does not have the unstable element
- https://github.com/prettier/plugin-php/issues/2380 - similar, but does not have the unstable element
Prettier 3.5.3
PHP Plugin 0.22.4
# Options (if any): None
module.exports = {
plugins: ["@prettier/plugin-php"],
};
Example 1
Input:
<?php
/**
* The template for displaying the footer
*/
?>
<div class="footer">
<?php
// Footer
get_template_part("template-parts/footer", "2022"); ?>
</div>
<?php wp_footer(); ?>
Output run 1:
<?php
/**
* The template for displaying the footer
*/
?>
<div class="footer">
<?php // Footer
get_template_part("template-parts/footer", "2022"); ?>
</div>
<?php wp_footer(); ?>
Output run 2:
<?php
/**
* The template for displaying the footer
*/
?>
<div class="footer">
<?php // Footer
// Footer
get_template_part("template-parts/footer", "2022"); ?>
</div>
<?php wp_footer(); ?>
Output run 3: each successive run adds a new line with // Footer
Example 2
Input:
</main><!-- #main -->
</div><!-- #primary -->
<?php
// get_sidebar();
get_footer();
Output run 1:
</main><!-- #main -->
</div><!-- #primary -->
<?php // get_sidebar();
get_footer();
Output run 2:
</main><!-- #main -->
</div><!-- #primary -->
<?php // get_sidebar();
get_footer();
Example 3
Input:
<header class="page-header">
<h1 class="page-title">
<?php
/* translators: %s: search query. */
printf(
esc_html__("Search Results for: %s", "gpo18"),
"<span>" . get_search_query() . "</span>"
); ?>
</h1>
</header><!-- .page-header -->
Output run 1:
<header class="page-header">
<h1 class="page-title">
<?php /* translators: %s: search query. */
printf(
esc_html__("Search Results for: %s", "gpo18"),
"<span>" . get_search_query() . "</span>"
); ?>
</h1>
</header><!-- .page-header -->
Output run 2:
<header class="page-header">
<h1 class="page-title">
/* translators: %s: search query. */<?php
/* translators: %s: search query. */
printf(
esc_html__("Search Results for: %s", "gpo18"),
"<span>" . get_search_query() . "</span>"
); ?>
</h1>
</header><!-- .page-header -->
Output run 3:
<header class="page-header">
<h1 class="page-title">
/* translators: %s: search query. */ /* translators: %s: search query. */<?php
/* translators: %s: search query. */
printf(
esc_html__("Search Results for: %s", "gpo18"),
"<span>" . get_search_query() . "</span>"
); ?>
</h1>
</header><!-- .page-header -->
cc: @movva-gpu
- 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ự
-
Solved site promotion gate fails on runner PHP patch drift (expects 8.2.33, runner installs 8.2.34) Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
Automattic/blocks-engine#2161 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
Automattic/static-site-importer#1824 ·
-
[Chore] Keep one viget-block-generator skill and replicate it, instead of four tracked copies Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
-
Cannot reset column width Đang mở0. Needs triage bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
-
0. Needs triage 35-feedback bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100