/编码规范

PHPCS 编码规范扩展,让码满意

0.2.0 2024-02-02 23:39 UTC

This package is auto-updated.

Last update: 2024-09-03 01:04:51 UTC


README

有偏见的 PHP 编码规范规则,与 PHP_CodeSniffer 一起使用。

安装

$ composer require --dev rask/coding-standard

在你的 phpcs.xml

<config name="installed_paths" value="vendor/rask/coding-standard">

<rule ref="RaskCodingStandard" />

嗅探器

RaskCodingStandard.NamingConventions.VariableNaming

变量名必须是 snake_case,必须只包含 a-z0-9_,不能以下划线开头或结尾,并且不能包含连续的两个下划线。这也适用于类中的属性。

OK

$hello_world_1_how_are_you2

ERROR

$hello__World_how_are_you_

RaskCodingStandard.NamingConventions.FunctionNaming

函数名必须是 snake_case,必须只包含 a-z0-9_,不能以下划线开头或结尾,并且不能包含连续的两个下划线。这仅适用于 "松散" 函数,而不是方法。

OK

function hello_world() { ... }

ERROR

function helloWorld() { ... }

待办事项

[ ] 添加适当的测试,PHPCS 测试设置很糟糕,也许写一个新的或者从其他地方复制

许可证

MIT 许可证。查看 LICENSE.md