与 HTML 混合时,PhpStorm 不突出显示 .php 文件中的 PHP 代码

PhpStorm not highlighting PHP code inside a .php file when mixed with HTML

我在 PHPStorm 中遇到问题,当它与 HTML代码。

截图(点击放大):

如果我使 cache/restart 无效,它将在几秒钟内显示正确的突出显示。然而,在它 "calculates" 之后,它将 return 不突出显示它。

有这个设置吗?或者它只是一个普通的错误?

我读过有关语言注入的内容,但这似乎不适合它,因为它已经是一个 .php 文件并且 PHP 不在可注入语言列表中。

相关代码:

<?php
$works = "yes";
?>

<html>
<body>

<script>
    var shouldStillWorkAfterThis = true;
</script>

<?php
$works = "yes";
?>

<table>
    <tr>
        <td><?php $works = "yes"; ?></td>
    </tr>
</table>

<!-- lets try split syntax -->
<?php
if ($works) {
    ?>
    <table>
        <tr>
            <td><?= $works ?></td>
        </tr>
    </table>
    <?php $thisShouldToo = true; ?>
<?php } ?>

<!-- lets break it -->
<div id="someclass">
    <header>
        <div class="someotherclass">
            <div class="andanextraclass">
                <!-- include a file-->
                <?php include('somefile.php');?>
                <?php
                    $anythingHereIsNowBroken = true;
                ?>
            </div>
        </div>
    </header>
</div>

</body>
</html>

语言注入设置:

我在 MacOSX 10.9.5 上使用 PhpStorm 8.0.3。

根据您 Settings (Preferences on Mac) | Editor | Language Injections 的屏幕截图。

请从底部删除第 3 条语言注入规则("div" 的规则——范围列中有 "IDE")。

该规则将 HTML 注入 div 标签,告诉 IDE 将标签内的所有其他代码(甚至 PHP)视为 HTML/plain 文本.