pbweb/pbweb-coding-standard

PB Web 媒体编码标准

安装次数: 1,399

依赖: 0

建议者: 0

安全性: 0

星标: 0

关注者: 3

分支: 0

公开问题: 0

类型:coding-standard

2.0 2019-10-24 13:35 UTC

This package is auto-updated.

Last update: 2024-09-25 01:01:57 UTC


README

这是我们使用的PHPCS规则集。它基于Escape Studios提供的Symfony2编码标准,并具有以下特性:

  • 规则要求在字符串连接(.)运算符周围有空格
  • 规则要求在一元非(!)运算符周围有空格

它还禁用了一些规则,导致以下情况:

  • 现在允许在开括号后有空格(与一元非规则冲突,例如:some_func( ! $value)
  • 函数注释不再需要(PHP7类型提示可以解决这个问题)
  • 不需要按作用域排序类方法
  • 多行函数声明可以放在下一行

通过composer全局安装

使用以下命令安装:

composer global require pbweb/pbweb-coding-standard

然后配置phpcs以使用Pbweb标准

phpcs --config-set installed_paths ${HOME}/.composer/vendor/pbweb/pbweb-coding-standard/,${HOME}/.composer/vendor/escapestudios/symfony2-coding-standard/
phpcs --config-set default_standard Pbweb

仅在你自己的项目中安装

使用以下命令安装:

composer require pbweb/pbweb-coding-standard

Phing配置

示例phing目标

<target name="check:cs" description="Checks coding standard.">
    <echo msg="Checking coding standard..." />
    <phpcodesniffer standard="Pbweb"
                    showSniffs="true"
                    showWarnings="true">
        <fileset refid="sourcecode" />
        <formatter type="checkstyle" outfile="${dir.reports}/checkstyle.xml" />
        <config name="installed_paths" value="${project.basedir}/vendor/pbweb/pbweb-coding-standard,${project.basedir}/vendor/escapestudios/symfony2-coding-standard" />
    </phpcodesniffer>
</target>