Skip to content

Commit a6d3653

Browse files
xaloppmmoll
authored andcommitted
update documentation
1 parent e785d98 commit a6d3653

File tree

3 files changed

+62
-45
lines changed

3 files changed

+62
-45
lines changed

CONTRIBUTING.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
If you contribute code, please make sure it conforms to the
44
[PHPCS coding standard](https://github.com/squizlabs/PHP_CodeSniffer/blob/master/phpcs.xml.dist)
55
and that the unit tests still pass.
6+
Whenever possible, add an auto fixer for coding standard violations.
67

78
## Setup
89

MO4/ruleset.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
<exclude name="PSR2.Namespaces.UseDeclaration"/>
1212
<exclude name="Symfony.Commenting.ClassComment.Missing"/>
1313
<exclude name="Symfony.Commenting.License"/>
14-
<!-- <exclude name="Generic.Formatting.MultipleStatementAlignment"/> -->
1514
</rule>
1615

1716
<rule ref="Squiz.WhiteSpace.OperatorSpacing">

README.md

Lines changed: 61 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,6 @@ Provides a PHP CodeSniffer ruleset for the MO4 coding standard
1212
[![License](https://poser.pugx.org/mayflower/mo4-coding-standard/license)](https://packagist.org/packages/mayflower/mo4-coding-standard)
1313
[![composer.lock](https://poser.pugx.org/mayflower/mo4-coding-standard/composerlock)](https://packagist.org/packages/mayflower/mo4-coding-standard)
1414

15-
16-
## Requires
17-
18-
* [PHP CodeSniffer](https://github.com/squizlabs/PHP_CodeSniffer)
19-
* [Symfony Coding Standard](https://github.com/djoos/Symfony-coding-standard)
20-
2115
## MO4 Coding Standard
2216

2317
The MO4 Coding Standard is an extension of the [Symfony Coding Standard](http://symfony.com/doc/current/contributing/code/standards.html) and adds following rules:
@@ -40,45 +34,17 @@ The MO4 Coding Standard is an extension of the [Symfony Coding Standard](http://
4034
* There must be at least one space around operators, and (except for aligning multiline statements) at most one, see the
4135
[respective Squizlabs Sniff](https://github.com/squizlabs/PHP_CodeSniffer/wiki/Customisable-Sniff-Properties#squizwhitespaceoperatorspacing)
4236
we imported with `ignoreNewlines = false`
37+
38+
With this ruleset enabled, following [Symfony Coding Standard](http://symfony.com/doc/current/contributing/code/standards.html) rules are not enforced:
39+
* "`add doc blocks for all classes`": the doc block for classes can be omitted, if they add no value
40+
* "`the license block has to be present at the top of every PHP file, before the namespace`": the license block can be omitted
4341

44-
## Configuration
45-
46-
### MO4.Formatting.AlphabeticalUseStatements
47-
48-
The `order` property of the `MO4.Formatting.AlphabeticalUseStatements` sniff defines
49-
which function is used for ordering.
50-
51-
Possible values for order:
52-
* `dictionary` (default): based on [strcmp](http://php.net/strcmp), the namespace separator
53-
precedes any other character
54-
```php
55-
use Doctrine\ORM\Query;
56-
use Doctrine\ORM\Query\Expr;
57-
use Doctrine\ORM\QueryBuilder;
58-
```
59-
* `string`: binary safe string comparison using [strcmp](http://php.net/strcmp)
60-
```php
61-
use Doctrine\ORM\Query;
62-
use Doctrine\ORM\QueryBuilder;
63-
use Doctrine\ORM\Query\Expr;
42+
Most of the issues can be auto-fixed with `phpcbf`.
6443

65-
use ExampleSub;
66-
use Examples;
67-
```
68-
* `string-locale`: locale based string comparison using [strcoll](http://php.net/strcoll)
69-
* `string-case-insenstive`: binary safe case-insensitive string comparison [strcasecmp](http://php.net/strcasecmp)
70-
```php
71-
use Examples;
72-
use ExampleSub;
73-
```
44+
## Requires
7445

75-
```xml
76-
<rule ref="MO4.Formatting.AlphabeticalUseStatements">
77-
<properties>
78-
<property name="order" value="string-locale"/>
79-
</properties>
80-
</rule>
81-
```
46+
* [PHP](http://php.net) version 5.4 or later
47+
* [Composer](https://getcomposer.org/) is optional, but strongly recommended
8248

8349
## Installation
8450

@@ -145,12 +111,63 @@ Using [Composer](https://getcomposer.org/) is the preferred way.
145111

146112
phpcs --config-set default_standard MO4
147113

114+
## Configuration
115+
116+
### MO4.Formatting.AlphabeticalUseStatements
117+
118+
The `order` property of the `MO4.Formatting.AlphabeticalUseStatements` sniff defines
119+
which function is used for ordering.
120+
121+
Possible values for order:
122+
* `dictionary` (default): based on [strcmp](http://php.net/strcmp), the namespace separator
123+
precedes any other character
124+
```php
125+
use Doctrine\ORM\Query;
126+
use Doctrine\ORM\Query\Expr;
127+
use Doctrine\ORM\QueryBuilder;
128+
```
129+
* `string`: binary safe string comparison using [strcmp](http://php.net/strcmp)
130+
```php
131+
use Doctrine\ORM\Query;
132+
use Doctrine\ORM\QueryBuilder;
133+
use Doctrine\ORM\Query\Expr;
134+
135+
use ExampleSub;
136+
use Examples;
137+
```
138+
* `string-locale`: locale based string comparison using [strcoll](http://php.net/strcoll)
139+
* `string-case-insenstive`: binary safe case-insensitive string comparison [strcasecmp](http://php.net/strcasecmp)
140+
```php
141+
use Examples;
142+
use ExampleSub;
143+
```
144+
145+
To change the sorting order for your project, add this snippet to your custom `ruleset.xml`:
146+
147+
```xml
148+
<rule ref="MO4.Formatting.AlphabeticalUseStatements">
149+
<properties>
150+
<property name="order" value="string-locale"/>
151+
</properties>
152+
</rule>
153+
```
154+
155+
## Troubleshooting
156+
157+
If `phpcs` complains that MO4 is not installed, please check the installed coding standards with
158+
`phpcs -i` and that `installed_paths` is set correctly with `phpcs --config-show`
159+
160+
## Dependencies
161+
162+
* [PHP CodeSniffer](https://github.com/squizlabs/PHP_CodeSniffer)
163+
* [David Joos's Symfony Coding Standard](https://github.com/djoos/Symfony-coding-standard) ruleset for PHP CodeSniffer
164+
* [Composer installer for PHP_CodeSniffer coding standards](https://github.com/DealerDirect/phpcodesniffer-composer-installer)
165+
148166
## Contributing
149167

150168
See [CONTRIBUTING.md](CONTRIBUTING.md) for information.
151169

152-
## Credit
153-
154170
## License
155171

156172
This project is licensed under the MIT license.
173+
See the [LICENSE](LICENSE) file for details.

0 commit comments

Comments
 (0)