Plugin-php: <?php ?> tags removed if they only contain a comment

Created on 3 Apr 2018  路  3Comments  路  Source: prettier/plugin-php

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.

bug inline

Most helpful comment

Looks like this is still an issue

All 3 comments

@czosel @mgrip i have idea how we can rewrite <?php and ?> without complex logic as we have now. I will send PR. Also we should done this before alpha release.

Looks like this is still an issue

Actually wasn't fixed in #504

Was this page helpful?
0 / 5 - 0 ratings