Skip to content

Commit 01398c4

Browse files
committed
Update the rules
1 parent cebec36 commit 01398c4

File tree

3 files changed

+33
-27
lines changed

3 files changed

+33
-27
lines changed

README.md

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,18 +16,18 @@ You can also add it manually, like this, to get the latest version:
1616

1717
```json
1818
"require-dev": {
19-
"binary-cats/laravel-php-styles": "^1.0"
19+
"binary-cats/laravel-php-styles": "^2.0"
2020
},
2121
```
2222

2323
## Laravel
2424

2525
You can publish the stub file using
2626
```bash
27-
php artisan vendor:publish --provider=BinaryCats\\PhpStyles\\PhpStylesServiceProvider
27+
php artisan vendor:publish --provider=BinaryCats\\PhpStyles\\PhpStyleServiceProvider
2828
```
2929

30-
You should also add `.php_cs.cache` to your `.gitignore`.
30+
You should also add `.php-cs-fixer.cache` to your `.gitignore`.
3131

3232
## Config
3333

@@ -37,9 +37,7 @@ The package provides with the current set of [rules](./src/rules.php):
3737
return [
3838
'@Symfony' => true,
3939
'AdamWojs/phpdoc_force_fqcn_fixer' => true,
40-
'array_syntax' => ['syntax' => 'short'],
4140
'concat_space' => ['spacing' => 'one'],
42-
'final_class' => false,
4341
'new_with_braces' => true,
4442
'no_superfluous_phpdoc_tags' => false,
4543
'not_operator_with_successor_space' => true,
@@ -50,7 +48,7 @@ return [
5048

5149
## Integration
5250

53-
PHP-CS-Fixer is going to expect your configuration to be in a `/.php_cs.dist` file.
51+
PHP-CS-Fixer is going to expect your *default* configuration to be in a `/.php-cs-fixer.dist.php` file.
5452

5553
```php
5654
<?php
@@ -75,7 +73,7 @@ And now you can run the fix like this:
7573

7674
If you want to see the progress as you go by:
7775
```bash
78-
./vendor/bin/php-cs-fixer fix --verbose --show-progress=estimate
76+
./vendor/bin/php-cs-fixer fix --verbose --show-progress=dots
7977
```
8078

8179
If you want to add this to composer alias, you can add this to your `composer.json`:
@@ -88,17 +86,28 @@ If you want to add this to composer alias, you can add this to your `composer.js
8886

8987
## Advanced Use
9088

91-
If you want to change the rules, disable, or add your own, simply update `.php_cs.dist` in your project's root:
89+
If you want to change the rules, disable, or add your own, simply update `.php-cs-fixer.dist.php` in your project's root:
9290

9391
```php
92+
...
9493
return BinaryCats\PhpStyles\styles($finder, [
95-
// turn the force FQCN fixer off
96-
'AdamWojs/phpdoc_force_fqcn_fixer' => false,
9794
// Do not wrap concat . with spaces
9895
'concat_space' => ['spacing' => 'none'],
9996
]);
10097
```
10198

99+
If you want to add more custom fixers, there is a third argument:
100+
```php
101+
...
102+
return BinaryCats\PhpStyles\styles($finder, [
103+
// turn the force FQCN fixer off
104+
'AdamWojs/phpdoc_force_fqcn_fixer' => false,
105+
], [
106+
new \AdamWojs\PhpCsFixerPhpdocForceFQCN\Fixer\Phpdoc\ForceFQCNFixer,
107+
]);
108+
109+
```
110+
102111
## Change log
103112

104113
Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

src/helpers.php

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,26 +2,22 @@
22

33
namespace BinaryCats\PhpStyles;
44

5-
use AdamWojs\PhpCsFixerPhpdocForceFQCN\Fixer\Phpdoc\ForceFQCNFixer;
65
use PhpCsFixer\Config;
76
use PhpCsFixer\Finder;
87

98
/**
109
* @param \PhpCsFixer\Finder $finder
1110
* @param array $rules
11+
* @param array $fixers
1212
*
1313
* @return \PhpCsFixer\Config
1414
*/
15-
function styles(Finder $finder, array $rules = []): Config
15+
function styles(Finder $finder, array $rules = [], array $fixers = []): Config
1616
{
17-
$rules = array_merge(require __DIR__.'/rules.php', $rules, [
18-
'AdamWojs/phpdoc_force_fqcn_fixer' => true,
19-
]);
17+
$rules = array_merge(require __DIR__.'/rules.php', $rules);
2018

2119
return Config::create()
22-
->registerCustomFixers([
23-
new ForceFQCNFixer(),
24-
])
20+
->registerCustomFixers($fixers)
2521
->setFinder($finder)
2622
->setRiskyAllowed(true)
2723
->setRules($rules);

src/rules.php

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
11
<?php
22

3-
// last reviewed: v1.0.0 Binary Kitten
3+
// last reviewed: v2.0.0 Binary Kitten
44

55
return [
6-
'@Symfony' => true,
7-
'array_syntax' => ['syntax' => 'short'],
8-
'concat_space' => ['spacing' => 'one'],
9-
'final_class' => false,
10-
'new_with_braces' => true,
11-
'no_superfluous_phpdoc_tags' => false,
6+
'@Symfony' => true,
7+
'array_syntax' => ['syntax' => 'short'],
8+
'concat_space' => ['spacing' => 'one'],
9+
'final_class' => false,
10+
'new_with_braces' => true,
11+
'no_superfluous_phpdoc_tags' => false,
1212
'not_operator_with_successor_space' => true,
13-
'ordered_imports' => ['imports_order' => ['class', 'function', 'const'], 'sort_algorithm' => 'alpha'],
14-
'phpdoc_separation' => false,
13+
'ordered_imports' => ['sort_algorithm' => 'alpha'],
14+
'php_unit_method_casing' => ['case' => 'snake_case'],
15+
'phpdoc_separation' => false,
1516
];

0 commit comments

Comments
 (0)