Repository: prettier/plugin-php

Issue #324: <?php ?> tags removed if they only contain a comment
Created: 2018-04-03T14:48:33Z
PHP: 7.0
Node: 9
prettier-php: 26c6262
prettier: d676188
Error
./node_modules/.bin/prettier --debug-check ./test2.php

[error] test2.php: ast(input) !== ast(prettier(input))
[error] Index:
[error] ===================================================================
[error] ---
[error] +++
[error] @@ -4,5 +4,5 @@
[error]      {
[error]        "kind": "inline",
[error] -      "value": "<div class=\"panel-collection\" data-modular-content-collection>\n\t"
[error] +      "value": "/**\n * The default view for rendering a collection of modular panels.\n * Override this by creating modular-content/collection-wrapper.php in\n * your theme directory.\n *\n * IMPORTANT: the data attribute is REQUIRED for the live preview iframe to function.\n *\n * @var string $panels The rendered HTML of the panels\n */\n\n<div class=\"panel-collection\" data-modular-content-collection>\n\t"
[error]      },
[error]      {
[error]
[error] Index:
[error] ===================================================================
[error] ---
[error] +++
[error] @@ -1,4 +1,2 @@
[error] -<?php
[error] -
[error]  /**
[error]   * The default view for rendering a collection of modular panels.
[error] @@ -10,5 +8,5 @@
[error]   * @var string $panels The rendered HTML of the panels
[error]   */
[error] -?>
[error] +
[error]  <div class="panel-collection" data-modular-content-collection>
[error]  	<?php echo $panels; ?>
[error]

Input
<?php

/**
 * The default view for rendering a collection of modular panels.
 * Override this by creating modular-content/collection-wrapper.php in
 * your theme directory.
 *
 * IMPORTANT: the data attribute is REQUIRED for the live preview iframe to function.
 *
 * @var string $panels The rendered HTML of the panels
 */
?>
<div class="panel-collection" data-modular-content-collection>
	<?php echo $panels; ?>
</div>
Output
/**
 * The default view for rendering a collection of modular panels.
 * Override this by creating modular-content/collection-wrapper.php in
 * your theme directory.
 *
 * IMPORTANT: the data attribute is REQUIRED for the live preview iframe to function.
 *
 * @var string $panels The rendered HTML of the panels
 */

<div class="panel-collection" data-modular-content-collection>
	<?php echo $panels; ?>
</div>
Expected Output
<?php

/**
 * The default view for rendering a collection of modular panels.
 * Override this by creating modular-content/collection-wrapper.php in
 * your theme directory.
 *
 * IMPORTANT: the data attribute is REQUIRED for the live preview iframe to function.
 *
 * @var string $panels The rendered HTML of the panels
 */
?>
<div class="panel-collection" data-modular-content-collection>
	<?php echo $panels; ?>
</div>

I would expect the <?php ?> tags to still be printed, so that the PHP block comment is not echoed to the output.

Duplicate issue #472: Bug on comment blocks.
Created: 2018-07-18T11:24:43Z
The comment is placed outside the php tag.
Code xx.
<?php

// =============================================================================
// VIEWS/ENERGY/WOOCOMMERCE.PHP
// -----------------------------------------------------------------------------
// WooCommerce page output for energy.
// =============================================================================

get_header();

?>

Output:
// =============================================================================
// VIEWS/ENERGY/WOOCOMMERCE.PHP
// -----------------------------------------------------------------------------
// WooCommerce page output for energy.
// =============================================================================

<?php
get_header();
?>

So now the content is outside the php tag and interpreted as text

Closing comment (2018-07-18T19:26:00Z): Duplicate #324