prettier / prettier/plugin-php
Breaks if comments precede an include statement in mixed HTML/PHP files
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- PHP
- Sterne
- 1.9k
- Forks
- 139
- PR-Merge-Kennzahlen
- Keine gemergten PRs in 30 T.
Beschreibung
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(); ?>
Beitragsleitfaden
Erste Schritte
- Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
- Forke das Repository und arbeite in einem Branch.
- Öffne einen Pull Request, der die Issue-Nummer nennt.
Rechercherichtung
Reproduziere die Eingabe im verknüpften Prettier PHP playground und vergleiche sie mit der gemeldeten Ausgabe, wobei der Fokus auf Kommentaren vor include-Anweisungen in gemischten HTML/PHP-Templates liegt. Verfolge den Einstiegspunkt des Formatierers für diesen Playground-Fall; als erledigt gilt, dass der Kommentar nicht dupliziert wird, das schließende PHP-Trennzeichen nicht vorzeitig eingefügt wird und include korrekt formatiert bleibt.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- php, wordpress
- Bereich
- tooling
- Issue-Typ
- Bug
- Schwierigkeit
- 3/5
- Geschätzter Aufwand
- 1-2 Tage
- Aktivitätsstatus
- Veraltet
- Klarheit
- Klar beschrieben
- Anfängerfreundlichkeit
- 45/100