This is mostly a workaround for the limitations put upon by @prettier/plugin-php, like not supporting <?
or a trailing ?>
and not dealing well with HTML and PHP mixed together.
This plugin works around them in various ways, like replacing <?
for <?php
proper, and first formatting the PHP code and then formatting it as HTML code.
It seems to work in my tests so far, but it is undertested, so unconsidered edge cases are very likely to occur.
WARNING: By leveraging the existing HTML and PHP plugins, we need to add them and prettier to the dependencies, which can lead to unexpected results if the code is formatted using a different version of prettier.
- Fails with
<?php
,<=
, or?>
when in an escaped position, like comments or string literals.