Skip to content

Commit e35f00f

Browse files
Init rules
0 parents  commit e35f00f

File tree

5 files changed

+142
-0
lines changed

5 files changed

+142
-0
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
.idea
2+
vendor/

LICENSE

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
BSD 3-Clause License
2+
3+
Copyright (c) 2019, StreamCommon Team
4+
All rights reserved.
5+
6+
Redistribution and use in source and binary forms, with or without
7+
modification, are permitted provided that the following conditions are met:
8+
9+
* Redistributions of source code must retain the above copyright notice, this
10+
list of conditions and the following disclaimer.
11+
12+
* Redistributions in binary form must reproduce the above copyright notice,
13+
this list of conditions and the following disclaimer in the documentation
14+
and/or other materials provided with the distribution.
15+
16+
* Neither the name of the copyright holder nor the names of its
17+
contributors may be used to endorse or promote products derived from
18+
this software without specific prior written permission.
19+
20+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
24+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
27+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
28+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

README.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# StreamCommon Team Coding Standard
2+
3+
## Installation
4+
1. Install the module via composer:
5+
* Console run:
6+
```console
7+
composer require --dev streamcommon/coding-standard
8+
```
9+
* Or add into your `composer.json`:
10+
```json
11+
"require-dev": {
12+
"streamcommon/coding-standard": "*"
13+
}
14+
```
15+
2. Add composer scripts into your `composer.json`:
16+
```json
17+
"scripts": {
18+
"cs-check": "phpcs",
19+
"cs-fix": "phpcbf"
20+
}
21+
```
22+
3. Create file `phpcs.xml`:
23+
```xml
24+
<?xml version="1.0"?>
25+
<ruleset name="StreamCommon Team Coding Standard">
26+
<rule ref="./vendor/streamcommon/coding-standard/ruleset.xml"/>
27+
<file>bin</file>
28+
<file>config</file>
29+
<file>lib</file>
30+
<file>src</file>
31+
<file>test</file>
32+
</ruleset>
33+
```
34+
## Usage
35+
Run: `composer cs-check` OR `composer cs-fix`
36+
37+
## Customize
38+
See https://github.com/squizlabs/PHP_CodeSniffer/wiki/Annotated-ruleset.xml

composer.json

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"name": "streamcommon/coding-standard",
3+
"description": "StreamCommon Team Coding Standard",
4+
"license": "BSD-3-Clause",
5+
"type": "library",
6+
"keywords": [
7+
"streamcommon",
8+
"coding standard"
9+
],
10+
"require": {
11+
"squizlabs/php_codesniffer": "^3.4.0"
12+
}
13+
}

ruleset.xml

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
<?xml version="1.0"?>
2+
<ruleset name="StreamCommon Team Coding Standard">
3+
<description>StreamCommon Team Coding Standard</description>
4+
<arg value="p"/>
5+
<arg name="colors"/>
6+
<rule ref="PSR2">
7+
<exclude name="PSR2.Namespaces.UseDeclaration.MultipleDeclarations"/>
8+
</rule>
9+
<rule ref="Generic.Arrays.DisallowLongArraySyntax"/>
10+
<rule ref="Generic.Formatting.SpaceAfterNot">
11+
<properties>
12+
<property name="spacing" value="0"/>
13+
</properties>
14+
</rule>
15+
<rule ref="Generic.CodeAnalysis.EmptyStatement">
16+
<exclude name="Generic.CodeAnalysis.EmptyStatement.DetectedCatch"/>
17+
</rule>
18+
<rule ref="Generic.Formatting.SpaceAfterCast">
19+
<properties>
20+
<property name="spacing" value="1"/>
21+
</properties>
22+
</rule>
23+
<rule ref="Generic.Strings.UnnecessaryStringConcat">
24+
<properties>
25+
<property name="allowMultiline" value="true"/>
26+
</properties>
27+
</rule>
28+
<rule ref="Generic.PHP.SAPIUsage"/>
29+
<rule ref="Squiz.Functions.GlobalFunction"/>
30+
<rule ref="Squiz.WhiteSpace.OperatorSpacing">
31+
<properties>
32+
<property name="ignoreNewlines" value="true"/>
33+
</properties>
34+
</rule>
35+
<rule ref="Squiz.WhiteSpace.SuperfluousWhitespace">
36+
<properties>
37+
<property name="ignoreBlankLines" value="false"/>
38+
</properties>
39+
</rule>
40+
<rule ref="Squiz.PHP.LowercasePHPFunctions"/>
41+
<rule ref="Squiz.Strings.ConcatenationSpacing">
42+
<properties>
43+
<property name="spacing" value="1" />
44+
<property name="ignoreNewlines" value="true"/>
45+
</properties>
46+
</rule>
47+
<rule ref="Squiz.Strings.DoubleQuoteUsage"/>
48+
<rule ref="Squiz.Strings.DoubleQuoteUsage.ContainsVar">
49+
<message>Variable "%s" not allowed in double quoted string; use sprintf() or concatenation instead</message>
50+
</rule>
51+
<rule ref="Squiz.Strings.EchoedStrings"/>
52+
<rule ref="Squiz.WhiteSpace.FunctionOpeningBraceSpace"/>
53+
<rule ref="Squiz.WhiteSpace.LogicalOperatorSpacing"/>
54+
<rule ref="Squiz.WhiteSpace.SemicolonSpacing"/>
55+
<rule ref="Squiz.WhiteSpace.SuperfluousWhitespace">
56+
<properties>
57+
<property name="ignoreBlankLines" value="false"/>
58+
</properties>
59+
</rule>
60+
</ruleset>

0 commit comments

Comments
 (0)