nicwortel/coding-standard

我的PHP CodeSniffer规则集

安装次数: 4,855

依赖项: 3

建议者: 0

安全: 0

星标: 1

关注者: 2

分支: 0

开放问题: 0

类型:phpcodesniffer-standard

v2.3.0 2024-01-11 15:46 UTC

This package is auto-updated.

Last update: 2024-09-11 17:10:14 UTC


README

Build status License Packagist version PHP version from Packagist

这是我为PHP CodeSniffer设计的规则集。它基于PSR-12 扩展编码风格,并添加了来自Slevomat 编码规范的检查。

安装

composer require --dev squizlabs/php_codesniffer nicwortel/coding-standard

使用方法

创建一个phpcs.xml文件

<?xml version="1.0" encoding="UTF-8"?>
<ruleset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:noNamespaceSchemaLocation="vendor/squizlabs/php_codesniffer/phpcs.xsd">
    <arg name="basepath" value="."/>
    <arg name="cache" value=".phpcs-cache"/>
    <arg name="colors"/>
    <arg name="extensions" value="php"/>

    <!-- Show progress and sniff names -->
    <arg value="ps" />

    <file>src/</file>

    <rule ref="NicWortel"/>
</ruleset>

然后你可以运行vendor/bin/phpcs