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版本信息,分类,包体,作者,许可证书,链接。

结束

你学会了吗?


Warning: copy(): SSL operation failed with code 1. OpenSSL Error messages: error:14090086:SSL routines:ssl3_get_server_certificate:certificate verify failed in /opt/lampp/htdocs/wordpresssummer/wp-content/themes/summerleaf/inc/summer_setting.php on line 546

Warning: copy(): Failed to enable crypto in /opt/lampp/htdocs/wordpresssummer/wp-content/themes/summerleaf/inc/summer_setting.php on line 546

Warning: copy(https://www.wordpressleaf.com/wp-content/themes/summerleaf/images/tx/43.png): failed to open stream: operation failed in /opt/lampp/htdocs/wordpresssummer/wp-content/themes/summerleaf/inc/summer_setting.php on line 546

发表评论

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