php_codesniff,规范四:PHP_CodeSniffer 开发规范示例

[TOC]

#(一)函数中的逗号问题

英文:`no space found after comma in function all`

中文:`在函数的逗号后面找不到空格`

错误:

![mark](http://qiniu.newthink.cc/blog/180307/IFF4dl7KiD.png)

正确:

>函数中间多了一个逗号

![mark](http://qiniu.newthink.cc/blog/180307/8mAjLdiKm5.png)

# (二)函数判断空格

英文:`there must be a single space between the closing parenthesis and the opening brace of a multi-line IF statement;found 0 spaces`

中文:`在一个多行if语句的结束括号和开括号之间必须有一个空格;找到0个空格。`

错误:

![mark](http://qiniu.newthink.cc/blog/180307/d08l062D3f.png)

正确:

![mark](http://qiniu.newthink.cc/blog/180307/kmldAhHgf8.png)

# (三)行字数限制

英文:`line exceeds 85 characters;contains 89 characters`

中文:`行超过85个字符;包含89个字符`

错误:

![mark](http://qiniu.newthink.cc/blog/180307/8DCKcfCJ6d.png)

解决方法:暂无

# (四)`class` 行尾

1、换行符

英文:`expected 1 newline at end of file`

中文:`预计在文件结尾处有1个换行符`

2、多一行

错误:

![mark](http://qiniu.newthink.cc/blog/180308/4g5lllEf5c.png)

正确:

![mark](http://qiniu.newthink.cc/blog/180308/FA851eKG0i.png)

# (五)默认参数放在最后

英文:

`phpcs:Arguments with default values must be at the end of the argument list`

中文:`phpcs:具有默认值的参数必须位于参数列表的末尾`

错误写法:

![mark](http://qiniu.newthink.cc/blog/180309/J5Lg14601a.png)

正确写法:

![mark](http://qiniu.newthink.cc/blog/180309/6e4Da8dJJj.png)

# (六)开口位置

英文:`Opening brace should be on a new line`

中文:`开口支撑应该在一个新的线上`

错误写法:

![mark](http://qiniu.newthink.cc/blog/180309/JH5kmF2gbC.png)

正确写法:

![mark](http://qiniu.newthink.cc/blog/180309/a8lhG9G0KB.png)

# (七) 参数有空格

错误写法:

![mark](http://qiniu.newthink.cc/blog/180309/2eFC33m6fE.png)

正确写法:

![mark](http://qiniu.newthink.cc/blog/180309/4aDHgEaGec.png)

# (八)依赖注入

错误:

![mark](http://qiniu.newthink.cc/blog/180310/76fbbl4EeL.png)

正确:

![mark](http://qiniu.newthink.cc/blog/180612/fEAiaJB6FK.png)

英文:`A number of parameters,their name or types(if any) in PHPDoc comment do not match the ones in resective funcdtion or method declaration.`

中文:`PHPDoc注释中的一些参数,它们的名称或类型(如果有的话)与切除函数或方法声明中的参数不匹配。`

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值