The following valid PHP code showcases a couple of issues I've seen with the formatter:
<html>
<body>
<script>
var test1 = '<?= $_SERVER['PHP_SELF'] ?>';
var test2 = "<?= true ? htmlentities('"""') : ''?>";
var test3 = <?= time() ?>;
</script>
</body>
</html>
When formatting this code, it results in the following screwed up code:
<html>
<body>
<script>
var test1 = '<?= $_SERVER['
PHP_SELF '] ?>';
var test2 = "<?= true ? htmlentities('"
""
') : '
' ?>";
var test3 = < ? = time() ? > ;
</script>
</body>
</html>
Thanks for fixing this!
Actually it's not completely fixed, here is another test case which goes wrong:
<html><body><script>
var test = {
<?= $condition ? 'item1' : 'item2' ?>: <?= $data ?>
};
</script></body></html>
Output after formatting:
<html>
<body>
<script>
var test = {
<
? php ? > : <?= $condition ? 'item1' : 'item2' ?>
};
</script>
</body>
</html>
Thanks, I didn't spot any more formatting issues!

version 1.1.4
@saurfang587 please post code, not screenshots. ~I cant reproduce this~. When I format a similar snippet I get the following.
Edit: looks like the php tag at the top is what prevents it from formatting
Before format:
<script>
<?php $this->foo() ?> //this breaks below formatting
function
_test(myVar)
{
$('.selector').picker({
"a":
true,
"b":
myVar
});
}
</script>
After format:
<script>
function
_test(myVar) {
$('.selector').picker({
"a": true,
"b": myVar
});
}
</script>
@saurfang587 this is upstream - https://github.com/beautify-web/js-beautify/issues/1687
Place a comment before the first php tag as a workaround.
Most helpful comment
Actually it's not completely fixed, here is another test case which goes wrong:
Output after formatting: