我们可以按照WordPress编码标准在VS Code中设置Intelephense吗?

问题描述

我正在使用VS Code中的PHPCS和PHPCBF进行wordpress开发。
(按照https://github.com/tommcfarlin/phpcs-wpcs-vscode中提到的说明进行操作)

虽然PHPCBF按照WPCS格式化代码,但我仍然觉得代码看起来非常丑陋,尤其是当PHP文档中包含Html标记时。

当我使用Intelephense格式化PHP代码时,该代码看起来很悦目,包括适当缩进的Html标签。使用Intelephense的权衡是代码不再兼容WPCS。在Intelephense中可以选择将wordpress包含在存根中,但这仅用于包含wordpress的特定功能,而与格式无关。

使用Intelephense格式化时会遇到一些问题:

  1. 打开后和右括号(PHPcs)前没有空格
  2. 文件注释(PHPcs)前不能有空行
<?PHP
// this is a blank line inserted by Intelephense which is causing error no.2 provided in summary above
/**
 * This is a sample file
 *
 * @package something.
 * something something
 * something something
 */

get_header();
if (have_posts()) {
    while (have_posts()) {
// No space is inserted by Intelephense After opening and before Closing parenthesis which is causing error no.1 provided in summary above
        the_post(); ?>
        <h2>
            <a href="<?PHP the_permalink(); ?>"><?PHP the_title(); ?> </a>
        </h2>
        <?PHP the_content(); ?>
        <hr>
<?PHP
    }
}
get_footer();
?>

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)