如何解决我们可以按照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格式化时会遇到一些问题:
- 打开后和右括号(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 举报,一经查实,本站将立刻删除。