shlinkio/php-coding-standard
最新稳定版本:v2.5.0
Composer 安装命令:
composer require shlinkio/php-coding-standard
包简介
Coding standard used by shlink PHP projects
README 文档
README
This repository provides a PHP_CodeSniffer ruleset with the rules used by shlink PHP projects.
Usage
First, install this package using composer:
composer require shlinkio/php-coding-standard --dev
Then, update your phpcs.xml file, adding a rule with the reference to Shlinkio.
<?xml version="1.0"?> <ruleset name="Coding standard"> <description>Coding standard</description> <!-- display progress --> <arg value="p" /> <arg name="colors" /> <!-- inherit rules from: --> <rule ref="Shlinkio" /> <!-- [...] --> </ruleset>
Rules
This ruleset extends PSR-12 rules, and includes:
- Do not allow array long syntax [
array(...)]. - Make sure string concatenation operator is surrounded by spaces.
- Do not allow superfluous whitespaces.
- Do not allow unused use statements.
- Require alphabetically ordered use statements.
- Require strict comparisons (
===and!==instead of==and!=). - Require trailing comma on every element of multi-line arrays.
- Require trailing comma on every element of multi-line function calls.
- Require trailing comma on every element of multi-line function declarations.
- Enforce all global namespace classes, functions and constants to be explicitly imported.
- Require comments with single line written as one-liners [
/* @var SomeType **/]. - Make all class constants to have a visibility modifier (
public,protectedorprivate). - Require function arguments with a default
nullvalue to be defined as nullable (?string $foo = 'foo'). - Require function arguments to have a native type hint whenever possible.
- Require functions to have a native return type hint whenever possible.
- Require properties to have a native type hint whenever possible.
- Require non-capturing catch when the exception variable is not used.
- Format union types without spaces (
foo|bar) and enforcing null at the end for nullables (foo|bar|null).
统计信息
- 总下载量: 78.01k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 4
- 点击次数: 1
- 依赖项目数: 14
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2018-11-26