PHP CodeSniffer提示错误:Missing file doc comment

导语:叶子在使用Visual Studio Code编写PHP代码的时候遇到了一个错误:Missing file doc comment。这个错误的发生是因为PHP CodeSniffer要求规范PHP文件格式。

错误描述

severity: '错误'
message: 'Missing file doc comment'
at: '2,1'
source: 'phpcs'
code: 'undefined'

解决方法

我们需要按照PHP CodeSniffer标准的PHP编码规范来写PHP代码文件头部文档注释,例如下面的代码:

<?php
/**
* Test Doc
*
* PHP version 7
*
* @category File_Test
* @package File_Test1
* @author WordPressLeaf <1794674215@qq.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU General Public License
* @link Http://www.wordpressleaf.com
*/
$d = '12';
$c = '23';
echo $e = $d . $c;

一个标准的PHP文件头需要包含文档名称,php版本信息,分类,包体,作者,许可证书,链接。

结束

你学会了吗?

发表评论

邮箱地址不会被公开。 必填项已用*标注