承接 cn-consult/coding-standard 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

cn-consult/coding-standard

最新稳定版本:0.7

Composer 安装命令:

composer require cn-consult/coding-standard

包简介

Our Company-Wide Coding Standard based on PHP_CodeSniffer

README 文档

README

Our Company-Wide Coding Standard based on PHP_CodeSniffer.

Currently this is targeted for PHP-Code only, but it may also be used to sniff JS-Code or CSS, but we have no special Sniffs or Code for these languages.

Usage

To use this repository, add it as dev-dependency to your composer.json: composer require --dev cn-consult/coding-standard:dev-master.

Aftewards create a file phpcs.xml in your project root and add the following contents:

<?xml version="1.0"?>
<ruleset name="MyProject">
    <description>My cool project, using the CN-Consult PHPCS standard</description>
    <rule ref="vendor/cn-consult/coding-standard" />
    <exclude-pattern>vendor/*</exclude-pattern>
</ruleset>

Afterwards you can check your code by executing: vendor/bin/phpcs .

Development

To add new rules to our standard you should open up a youtrack-ticket and explain what you want to accomplish. You should add some examples that shows what the check should allow and/or disallow. When you get positive feedback you may implement your check. Before you implement a custom Sniff, it is a good idea to check if there perhaps already exists a Sniff that accomplishes what you want. Unfortunatly there is no single documentation that shows all available Sniffs. A good starting point may be https://github.com/squizlabs/PHP_CodeSniffer/wiki/Customisable-Sniff-Properties or having a look at the implemented Sniffs by name or searching after the required token in the sourcecode (for example T_FUNCTION). If there is no other way you may implement your own sniff by following this guide: https://github.com/squizlabs/PHP_CodeSniffer/wiki/Coding-Standard-Tutorial

After you added your sniff, you can run phpcs through the provided script in tests/run-manually.sh and check if it works and outputs the correct issues for test-files. If all is like expected please make sure that your new sniff is tested properly.

How to add new good tests

This is really easy. Just add additional files in the examples/good/ directory that you don't expect to generate any output, and run the unit-tests. Your new files will be picked up automatically.

How to add new bad tests

This is a bit more involved. First add an example file in the examples/bad/ directory that should trigger some issue. The use the tests/generate-expected-bad-output.php to verify that the file shows the issues you expect and create an accompanying expected-file. The generate-expected-bad-output.php will guide you through this process, just read its output.

统计信息

  • 总下载量: 9.52k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 2
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2020-03-10