1
- PHP Formatter
2
- =============
1
+ # PHP Formatter
2
+
3
3
[ ![ Build Status] ( https://travis-ci.org/mmoreram/php-formatter.png?branch=master )] ( https://travis-ci.org/mmoreram/php-formatter )
4
- [ ![ Scrutinizer Code Quality] ( https://scrutinizer-ci.com/g/mmoreram/php-formatter/badges/quality-score.png?b=master )] ( https://scrutinizer-ci.com/g/mmoreram/php-formatter/?branch=master )
5
- [ ![ Latest Stable Version] ( https://poser.pugx.org/mmoreram/php-formatter/v/stable.png )] ( https://packagist.org/packages/mmoreram/php-formatter )
6
- [ ![ Latest Unstable Version] ( https://poser.pugx.org/mmoreram/php-formatter/v/unstable.png )] ( https://packagist.org/packages/mmoreram/php-formatter )
7
4
8
5
This PHP formatter aims to provide you some bulk actions for you PHP projects to
9
6
ensure their consistency. None of them fixes PSR rules. If you want to fix PSR
10
- rules, please check [ fabpot/php-cs-fixer] ( https://github.com/fabpot/PHP-CS-Fixer ) .
11
-
12
- ## Tags
13
-
14
- * Use last unstable version ( alias of ` dev-master ` ) to stay in last commit
15
- * Use last stable version tag to stay in a stable release.
16
- * [ ![ Latest Unstable Version] ( https://poser.pugx.org/mmoreram/php-formatter/v/unstable.png )] ( https://packagist.org/packages/mmoreram/php-formatter )
17
- [ ![ Latest Stable Version] ( https://poser.pugx.org/mmoreram/php-formatter/v/stable.png )] ( https://packagist.org/packages/mmoreram/php-formatter )
7
+ rules, please check [ friendsofphp/php-cs-fixer] ( https://github.com/friendsofphp/PHP-CS-Fixer ) .
18
8
19
9
## Install
20
10
@@ -51,14 +41,15 @@ $ cp build/php-formatter.phar /usr/local/bin/php-formatter
51
41
52
42
### Compile
53
43
54
- Finally you can also compile your own version of the package. ( You need set ` phar.readonly = Off ` in your php.ini ).
44
+ Finally you can also compile your own version of the package. ( You need set
45
+ ` phar.readonly = Off ` in your php.ini ). For the compilation of this package you
46
+ need the [ box-project/box2] ( https://github.com/box-project/box2 ) library.
55
47
56
48
``` bash
57
49
$ git clone
[email protected] :mmoreram/php-formatter.git
58
50
$ cd php-formatter
59
51
$ composer update
60
- $ php bin/compile
61
- $ sudo chmod +x build/php-formatter.phar
52
+ $ box build -v
62
53
$ build/php-formatter.phar
63
54
```
64
55
@@ -136,8 +127,9 @@ Available commands:
136
127
help Displays help for a command
137
128
list Lists commands
138
129
formatter
139
- formatter:header:fix Ensures that all PHP files has header defined in config file
140
- formatter:use:sort Sort Use statements
130
+ formatter:header:fix Ensures that all PHP files has header defined in config file
131
+ formatter:strict:fix Ensures that all PHP files have strict mode defined in config file. Only valid for >=PHP7.0
132
+ formatter:use:sort Sort Use statements
141
133
` ` `
142
134
143
135
# ## Sort all Use Statements
@@ -148,21 +140,13 @@ process.
148
140
149
141
* command: `php-formatter formatter:use:sort`
150
142
* argument: path
143
+ * option: --exclude [***multiple***]
151
144
* option: --group [***multiple***]
152
145
* option: --group-type=***one***|***each***
153
146
* option: --sort-type=***alph***|***length***
154
147
* option: --sort-direction=***asc***|***desc***
155
148
* option: --dry-run [***no value***]
156
149
157
- # ### Dry run
158
-
159
- You can use this tool just to test the files will be modified, using option
160
- --dry-run
161
-
162
- ` ` ` bash
163
- $ php-formatter formatter:use:sort src/ --dry-run
164
- ` ` `
165
-
166
150
# ### Group
167
151
168
152
You can sort your Use statements using as many groups as you want (***--group***).
@@ -320,35 +304,9 @@ will check and fix that all PHP files have it properly.
320
304
321
305
* command: `php-formatter formatter:header:fix`
322
306
* argument: path
307
+ * option: --exclude [***multiple***]
323
308
* option: --dry-run [***no value***]
324
309
325
- # ### Dry run
326
-
327
- You can use this tool just to test the files will be modified, using the option
328
- --dry-run
329
-
330
- ` ` ` bash
331
- $ php-formatter formatter:header:fix src/ --dry-run
332
- ` ` `
333
-
334
- Your PHP Header definition must have this format.
335
-
336
- ` ` ` yml
337
- header: |
338
- /*
339
- * This file is part of the php-formatter package
340
- *
341
- * Copyright (c) 2014 Marc Morera
342
- *
343
- * For the full copyright and license information, please view the LICENSE
344
- * file that was distributed with this source code.
345
- *
346
- * Feel free to edit as you please, and have fun.
347
- *
348
- * @author Marc Morera <[email protected] >
349
- */
350
- ` ` `
351
-
352
310
# ## Fix all strict declarations
353
311
354
312
In your >=7.0 PHP applications you can use simple type declarations in your
@@ -359,6 +317,7 @@ exists and before the namespace declaration, you can use this command.
359
317
360
318
* command: `php-formatter formatter:strict:fix`
361
319
* argument: path
320
+ * option: --exclude [***multiple***]
362
321
* option: --dry-run [***no value***]
363
322
364
323
You can have three values here. If you define a boolean, then each file found
@@ -373,4 +332,31 @@ removed.
373
332
374
333
` ` ` yml
375
334
strict: '~'
376
- ` ` `
335
+ ` ` `
336
+
337
+ # # Exclude folders/files
338
+
339
+ You can exclude folders and files by using the multi-option `--exclude` as many
340
+ times as you need. This option works the same way the Symfony component
341
+ [Finder](http://symfony.com/doc/current/components/finder.html) works, so to
342
+ make sure you properly understand the way this option works, just check the
343
+ documentation.
344
+
345
+ ` ` ` bash
346
+ $ php-formatter formatter:header:fix src/ --exclude="vendor"
347
+ ` ` `
348
+
349
+ In that case, maybe the most used way, you will exclude all vendors from your
350
+ process.
351
+
352
+ # # Dry run
353
+
354
+ You can use this tool just to test the files will be modified, using option
355
+ --dry-run
356
+
357
+ ` ` ` bash
358
+ $ php-formatter formatter:use:sort src/ --dry-run
359
+ ` ` `
360
+
361
+ Any command from this library will never have any impact in your code as long as
362
+ you have defined this option.
0 commit comments