Skip to content

Commit 3c3badc

Browse files
author
Ethan Bray
committed
Initial commit of MessageCloud Coding Standard.
0 parents  commit 3c3badc

File tree

4 files changed

+79
-0
lines changed

4 files changed

+79
-0
lines changed

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
.idea
2+
/vendor/

README.md

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# MessageCloud Coding Standard
2+
3+
The PHP coding standard for MessageCloud.
4+
5+
## Installation
6+
7+
1. Require the package in your `composer.json`:
8+
```json
9+
{
10+
"repositories": [
11+
{
12+
"type": "vcs",
13+
"url": "[email protected]:MessageCloud/messagecloud-coding-standard.git"
14+
}
15+
],
16+
"require-dev": {
17+
"messagecloud/messagecloud-coding-standard": "^1.0"
18+
}
19+
}
20+
```
21+
22+
2. Create a PHP Code Sniffer configuration file `phpcs.xml`:
23+
```xml
24+
<?xml version="1.0"?>
25+
<ruleset name="MessageCloud Coding Standard">
26+
<rule ref="./vendor/messagecloud/messagecloud-coding-standard/ruleset.xml"/>
27+
28+
<!-- Path to check -->
29+
<file>./src</file>
30+
31+
<!-- Allow test methods to be snake case -->
32+
<rule ref="PSR1.Methods.CamelCapsMethodName">
33+
<exclude-pattern>./test</exclude-pattern>
34+
</rule>
35+
</ruleset>
36+
```

composer.json

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"name": "messagecloud/messagecloud-coding-standard",
3+
"description": "MessageCloud Coding Standard",
4+
"require": {
5+
"squizlabs/php_codesniffer": "^3.0"
6+
},
7+
"authors": [
8+
{
9+
"name": "Ethan Bray",
10+
"email": "[email protected]"
11+
}
12+
]
13+
}

ruleset.xml

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?xml version="1.0"?>
2+
<ruleset name="MessageCloud Coding Standard">
3+
<description>MessageCloud PHP Coding Standard. Essentially PSR2 with some modifications.</description>
4+
5+
<arg name="colors"/>
6+
<arg value="p"/>
7+
8+
<!-- PSR2 extends PSR1 -->
9+
<rule ref="PSR2"/>
10+
<rule ref="Generic.Arrays.DisallowLongArraySyntax"/>
11+
12+
<!--Extend the line length warning and error to 130 characters -->
13+
<rule ref="Generic.Files.LineLength">
14+
<properties>
15+
<property name="lineLimit" value="130"/>
16+
<property name="absoluteLineLimit" value="130"/>
17+
</properties>
18+
</rule>
19+
20+
<!--
21+
We exclude the PSR2 Use Declaration rule as it clashes with PHP7 style grouped Use statements.
22+
This is supposedly being fixed in a proposed PSR (https://github.com/php-fig/fig-standards/blob/master/proposed/extended-coding-style-guide.md)
23+
so we'll keep our eye on this.
24+
-->
25+
<rule ref="PSR2.Namespaces.UseDeclaration">
26+
<exclude-pattern>*</exclude-pattern>
27+
</rule>
28+
</ruleset>

0 commit comments

Comments
 (0)