Skip to content

Commit f0c418f

Browse files
committed
Initial commit
0 parents  commit f0c418f

File tree

5 files changed

+167
-0
lines changed

5 files changed

+167
-0
lines changed

.gitignore

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

LICENSE

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
Copyright (c) 2017 M6Web
2+
3+
Permission is hereby granted, free of charge, to any person obtaining a copy
4+
of this software and associated documentation files (the "Software"), to deal
5+
in the Software without restriction, including without limitation the rights
6+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7+
copies of the Software, and to permit persons to whom the Software is furnished
8+
to do so, subject to the following conditions:
9+
10+
The above copyright notice and this permission notice shall be included in all
11+
copies or substantial portions of the Software.
12+
13+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19+
THE SOFTWARE.

README.md

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
# php-cs-fixer-config
2+
3+
[`PHP CS Fixer`](http://github.com/FriendsOfPHP/PHP-CS-Fixer) config for M6Web components.
4+
5+
## Installation
6+
7+
Run
8+
9+
```
10+
$ composer require --dev m6web/php-cs-fixer-config
11+
```
12+
13+
## Usage
14+
15+
### Configuration
16+
17+
Create a configuration file `.php_cs` in the root of your project:
18+
19+
```php
20+
<?php
21+
22+
$config = new M6Web\CS\Config\Php71;
23+
24+
$config->getFinder()
25+
->in([
26+
__DIR__.'/src'
27+
])->exclude([
28+
'Tests'
29+
]);
30+
31+
return $config;
32+
```
33+
34+
### Git
35+
36+
Add `.php_cs.cache` (this is the cache file created by `php-cs-fixer`) to `.gitignore`:
37+
38+
```
39+
vendor/
40+
.php_cs.cache
41+
```
42+
43+
### Makefile
44+
45+
Create a `Makefile` with the targets below:
46+
47+
```Makefile
48+
# Coding Style
49+
50+
cs:
51+
./bin/php-cs-fixer fix --dry-run --stop-on-violation --diff
52+
53+
cs-fix:
54+
./bin/php-cs-fixer fix
55+
56+
cs-ci:
57+
./bin/php-cs-fixer fix --dry-run --using-cache=no --verbose
58+
```
59+
60+
## Fixing issues
61+
62+
### Manually
63+
64+
If you need to **check** issues locally, just run
65+
66+
```
67+
$ make cs
68+
```
69+
70+
If you need to **fix** issues locally, just run
71+
72+
```
73+
$ make cs-fix
74+
```
75+
76+
In your Continuous Integration, run
77+
78+
```
79+
$ make cs-ci
80+
```
81+
82+
## Credits
83+
84+
Developed by [M6Web](http://tech.m6web.fr/), inspired by [refinery29/php-cs-fixer-config](https://github.com/refinery29/php-cs-fixer-config).
85+
86+
## License
87+
88+
This project is licensed under the [MIT license](LICENSE).

composer.json

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
"name": "m6web/php-cs-fixer-config",
3+
"description": "PHP CS Fixer config for M6Web components",
4+
"keywords": ["CS", "CodingStyle"],
5+
"type": "library",
6+
"license": "MIT",
7+
"authors": [
8+
{
9+
"name": "M6Web",
10+
"email": "[email protected]",
11+
"homepage": "http://tech.m6web.fr/"
12+
}
13+
],
14+
"require": {
15+
"friendsofphp/php-cs-fixer": "^2.0"
16+
},
17+
"autoload": {
18+
"psr-4": {
19+
"M6Web\\CS\\Config\\": "src"
20+
}
21+
},
22+
"config": {
23+
"sort-packages": true
24+
}
25+
}

src/Php71.php

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?php
2+
3+
namespace M6Web\CS\Config;
4+
5+
use PhpCsFixer\Config;
6+
7+
final class Php71 extends Config
8+
{
9+
public function __construct()
10+
{
11+
parent::__construct('M6Web (PHP 7.1)');
12+
13+
$this->setRiskyAllowed(true);
14+
}
15+
16+
public function getRules()
17+
{
18+
$rules = [
19+
'@Symfony' => true,
20+
'array_syntax' => [
21+
'syntax' => 'short',
22+
],
23+
'no_unreachable_default_argument_value' => false,
24+
'braces' => [
25+
'allow_single_line_closure' => true,
26+
],
27+
'heredoc_to_nowdoc' => false,
28+
'phpdoc_summary' => false,
29+
];
30+
31+
return $rules;
32+
}
33+
}

0 commit comments

Comments
 (0)