prettier / plugin-php

Prettier PHP Plugin
https://loilo.github.io/prettier-php-playground/
MIT License
1.75k stars 130 forks source link

Issue in conditions followed by comments #2380

Open kotmatpockuh opened 4 months ago

kotmatpockuh commented 4 months ago

I have such code:

<p>
<?php
    if ($article['shop']['id'] === 10) { // TestShop
?>
        <img alt="" src="test.png">
<?php
    }
    $this->load();
?>
</p>

and it's formatted to:

<p>
<?php
if ($article["shop"]["id"] === 10) {<?php
    // TestShop
    ?>
        <img alt="" src="test.png">
<?php }
$this->load();
?>
</p>

so - an invalid <?php is added

See https://loilo.github.io/prettier-php-playground/#N4IgDgTgpgLjCWUIHkwIPYDsDOIBcok8mMA6vACYwAW+AHAAwA0IMAhgEblW14AsLAK7YoAFU648AMzYAbES2zEA5rKgBFQehhR8M+VBZhqYAGpIlWfCADsAOj4gWMCG3iyVAYXQBbH2wAFAAkA-BdBQxAOVwBjKABlGABPNWswJABaGNwWaABHQXhoANdlfz05BRBiEQgYErYytgqDAF8WKAp4GHQUNHgsSVA2bBgWkXbqzDBBMbwQAB4wAD4AHUwFgH5jMHWAAgO9+Ck9gAoAEjY6+Bi1AG0AcmxqdDAHgF1Hyg+9gF5-vYARgYAEo9sA9gB6SF7URQUbxF67TCbNaYQ4YvYLeA+ZR7OQwX6rEDEvbYCAxImseEwOxgTDKYlorY7faHVpsg7nGjwbAZZaydBsCinEEAbnWqPWC0hKxArSAA