Code Style for php and js in .phtml files for version 2023
Hi. I'm having some trouble with the code style config for some specific use cases.
In the .phtml template files where a new line is added after a php DocBlock ( a new line after each /** @noEscape */
) that should not happen. Eg:
<?= /** @noEscape */ $url ?>
will result in:
<?= /** @noEscape */
$url ?>
Also a new line is added before the closing script tag if the tag contains a type, if not the new line is not addeded (this case is fine) every time the formatting was running. Eg:
<script>
console.log('a');
</script>
<script type="text/x-magento-init">
{}
</script>
will result in:
<script>
console.log('a');
</script>
<script type="text/x-magento-init">
{}
</script>
And the last one is that a new line is added on every .php, html, pthml file at the end of the file.
Thank you so much in advance!
请先登录再写评论。
Hi Andrei,
Unfortunately, the number of lines after the block comment/PHPDoc is not configurable here, even on a plain PHP files. I have submitted a corresponding feature request for you:
https://youtrack.jetbrains.com/issue/WI-72910/Formatter-Configure-disable-new-lines-after-the-PHPDoc-block-comment
As for the new lines after the <script> tag, I was able to reproduce it with some other types as well (in some cases, it is indent that is infinitely added):
Looks like, this issue is covered by the following ticket:
https://youtrack.jetbrains.com/issue/WEB-24744/XHTML-Reformat-Code-command-repeatedly-inserts-blank-line-before-closing-script-in-script-block-of-unknown-type.
Thanks for the response and for the feature request!