问题描述
我正在使用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格式化时会遇到一些问题:
- 打开后和右括号(phpcs)前没有空格
- 文件注释(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 (将#修改为@)