interlutions / coding-standard
Interlutions 的内部 PHP 编码规范
v1.0
2018-11-16 10:46 UTC
Requires (Dev)
- phpunit/phpunit: ^4.0 || ^5.0 || ^6.0
- squizlabs/php_codesniffer: ^3.0
Conflicts
- squizlabs/php_codesniffer: <3 || >=4
This package is not auto-updated.
Last update: 2024-09-25 12:20:09 UTC
README
Interlutions 编码规范
我们(Interlutions)非常喜欢整洁的代码。因此,我们在各种框架、电子商务和内容管理系统之间拥有一个内部 PHP 编码规范。我们使用 PHP CodeSniffer 来确保其完整性。
编码规范的目标
- 使用现有标准(PSR-1,PSR-2)
- 跨框架编码规范(Symfony,TYPO3,Neos)
- 避免重复(包括代码、CVS 历史和文档之间的重复)
安装
如果您使用 Composer,只需使用以下命令将 Interlutions 编码规范包含到您的项目中:
composer req interlutions/coding-standard
用法
只需在项目根目录中创建一个 phpcs.xml.dist
文件,内容如下:
<?xml version="1.0"?> <ruleset name="interlutions-coding-standard"> <rule ref="vendor/interlutions/coding-standard/Interlutions"> <!-- If the standard is too hard, you can exclude some rules like this: --> <!-- <exclude name="Generic.Arrays.DisallowLongArraySyntax.Found" /> --> <!-- <exclude name="Generic.Files.LineLength.TooLong" /> --> </rule> </ruleset>
然后您可以这样执行 CodeSniffer:
vendor/bin/phpcs -s -p --colors src/
测试与开发
如果您仅使用此包,那么您应该没问题
- 下载 PHP CodeSniffer
- 在以下存储库中尝试它:
phpcs -d installed_paths=./Interlutions --standard=Interlutions/ruleset.xml data/*