HTML代码PhpStorm中分割成几个文件的块的检查


HTML code Inspection of blocks split up into several files in PhpStorm

有没有办法告诉PhpStorm只评估header.php和footer.php(就像浏览器在运行index.php时所做的那样)?

考虑一个包含4个文件的项目

  • index.php nbsp- nbsp;服务器端的东西,业务逻辑
  • header.php- html和一些php打印
  • item.php nbsp nbsp&nbsp-&nbsp html和一些php打印
  • footer.php&nbsp-&nbsp html和一些php打印

index.php

<?php
//Do some important stuff
include 'templates/header.php';
foreach($some_array as $item){
    include 'templates/item.php';
}
include 'templates/footer.php';

header.php

<!DOCTYPE html>
<html lang="en">
<head><title><?=$foo;?></title></head>
<body>
    <div id="main">

item.php

        <div class="item"><?=$var;?></div>     

footer.php

    </div> <!-- close #main -->
</body>
</html>

当我在这样的项目上执行"检查代码…"时,我会收到类型为"Closing tag match nothing(at line x)"和类似的错误/警告。有没有办法告诉PhpStorm只评估header.php和footer.php?我知道你可以从范围中选择"header.php"answers"footer.php",但我想把它们作为一个单元来评估。

目前似乎没有真正的解决方案,这是相应的票证:https://youtrack.jetbrains.com/issue/WEB-32239

我只是简单地将结束标记放入PHP echo语句中,例如<?php echo "</div></div>"; ?>而不是</div></div>,从而阻止PHPStorm分析HTML,从而删除了警告。