Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

Breaks if comments precede an include statement in mixed HTML/PHP files

Đang mở
#1,587 2 bình luận 0 reaction 0 người được giao Xem trên GitHub

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
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
php, wordpress
Lĩnh vực
tooling

Hướng nghiên cứu

Tái hiện input trong playground Prettier PHP được liên kết và so sánh với output đã báo cáo, tập trung vào các comment trước các câu lệnh include trong các template HTML/PHP hỗn hợp. Truy vết entry point của formatter cho trường hợp playground này; được xem là hoàn tất khi comment không bị nhân đôi, dấu phân cách đóng PHP không được chèn quá sớm và include vẫn được format đúng.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

bug comments inline

When running the plugin on a Wordpress template file with some commented lines, behaviour is not as expected.

In this example, the comment line (line 22 in the playground) // $feed_section_class = 'has-top-padding grey-bg'; somehow is duplicated and the closing ?> is inserted prematurely.

@prettier/plugin-php v0.15.2
Playground link

Input:

<?php

/*
Template Name: File
*/

get_header(); ?>

<?php
$home_url = home_url();
$theme_path = get_template_directory_uri();
?>

<main>
	<?php include locate_template('content-product-secondary-nav.php'); ?>

  <section>
    <h1>Title</h1>
    <p>Some content here</p>
  </section>

	<?php // $feed_section_class = 'has-top-padding grey-bg';
 // include( locate_template( 'content-brilliance-feeds.php' ) );
 include locate_template('content-sub-footer.php'); ?>
</main>

<?php get_template_part('content', 'brochure-popup'); ?>
<?php get_template_part('content', 'quote-popup'); ?>

<?php get_footer(); ?>

Output:

<?php

/*
Template Name: File
*/

get_header(); ?>

<?php
$home_url = home_url();
$theme_path = get_template_directory_uri();
?>

<main>
	<?php include locate_template('content-product-secondary-nav.php'); ?>

  <section>
    <h1>Title</h1>
    <p>Some content here</p>
  </section>

	<?php // $feed_section_class = 'has-top-padding grey-bg';
// $feed_section_class = 'has-top-padding grey-bg';
?>// include( locate_template( 'content-brilliance-feeds.php' ) );
 include locate_template('content-sub-footer.php'); ?>
</main>

<?php get_template_part('content', 'brochure-popup'); ?>
<?php get_template_part('content', 'quote-popup'); ?>

<?php get_footer(); ?>

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

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. 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.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của prettier/plugin-php

Tất cả issue của prettier/plugin-php

Issue tương tự

Thêm issue về PHP

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.