@@ -5,6 +5,17 @@ PHP Formatter
55[ ![ Latest Stable Version] ( https://poser.pugx.org/mmoreram/php-formatter/v/stable.png )] ( https://packagist.org/packages/mmoreram/php-formatter )
66[ ![ Latest Unstable Version] ( https://poser.pugx.org/mmoreram/php-formatter/v/unstable.png )] ( https://packagist.org/packages/mmoreram/php-formatter )
77
8+ This PHP formatter aims to provide you some bulk actions for you PHP projects to
9+ ensure their consistency. Any 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 )
18+
819## Install
920
1021Install PHP Formatter in this way:
@@ -76,13 +87,27 @@ use-sort:
7687 group-type : each
7788 sort-type : alph
7889 sort-direction : asc
90+
91+ header : |
92+ /**
93+ * This file is part of the php-formatter package
94+ *
95+ * Copyright (c) 2014 Marc Morera
96+ *
97+ * For the full copyright and license information, please view the LICENSE
98+ * file that was distributed with this source code.
99+ *
100+ * Feel free to edit as you please, and have fun.
101+ *
102+ * @author Marc Morera <yuhu@mmoreram.com>
103+ */
79104` ` `
80105
81106you can also define where to search the ` .formatter.yml` file using the
82107` --config|-c` option
83108
84109` ` ` bash
85- $ php-formatter use:sort src/ --config="src/"
110+ $ php-formatter formatter: use:sort src/ --config="src/"
86111` ` `
87112
88113# # Commands
@@ -107,10 +132,11 @@ Options:
107132 --no-interaction -n Do not ask any interactive question.
108133
109134Available commands:
110- help Displays help for a command
111- list Lists commands
112- use
113- use:sort Sort Use statements
135+ help Displays help for a command
136+ list Lists commands
137+ formatter
138+ formatter:header:fix Ensures that all PHP files has header defined in config file
139+ formatter:use:sort Sort Use statements
114140` ` `
115141
116142# ## Sort all Use Statements
@@ -119,7 +145,7 @@ You can sort your Use Statements in a very different ways. For this command you
119145must provide as an argument the path where to look for the PHP files you want to
120146process.
121147
122- * command: `php-formatter use:sort`
148+ * command: `php-formatter formatter: use:sort`
123149* argument: path
124150* option: --group [***multiple***]
125151* option: --group-type=***one***|***each***
@@ -133,7 +159,7 @@ You can use this tool just to test the files will be modified, using option
133159--dry-run
134160
135161` ` ` bash
136- $ php-formatter use:sort src/ --dry-run
162+ $ php-formatter formatter: use:sort src/ --dry-run
137163` ` `
138164
139165# ### Group
@@ -146,7 +172,7 @@ Common group is named `_main` and if is not specified, is placed in the
146172begining. You can define where to place this group with `--group` option
147173
148174` ` ` bash
149- $ php-formatter use:sort src/ --group="Mmoreram" --group="_main" --group="Symfony"
175+ $ php-formatter formatter: use:sort src/ --group="Mmoreram" --group="_main" --group="Symfony"
150176` ` `
151177
152178This command will sort the code like this
@@ -169,7 +195,7 @@ Finally, the `--group-type` defines if you want one `use` literal in every
169195namespace line
170196
171197` ` ` bash
172- $ php-formatter use:sort src/ --group="Mmoreram" --group-type="each"
198+ $ php-formatter formatter: use:sort src/ --group="Mmoreram" --group-type="each"
173199` ` `
174200
175201This command will sort the code like this
@@ -187,7 +213,7 @@ use Mmoreram\MySecondClass;
187213or if you want only one use for all group.
188214
189215` ` ` bash
190- $ php-formatter use:sort src/ --group="Mmoreram" --group-type="one"
216+ $ php-formatter formatter: use:sort src/ --group="Mmoreram" --group-type="one"
191217` ` `
192218
193219This command will sort the code like this
@@ -208,7 +234,7 @@ There are two options of sorting. You can sort your namespaces alphabetically
208234***(default value)***
209235
210236` ` ` bash
211- $ php-formatter use:sort src/ --sort-type="alph"
237+ $ php-formatter formatter: use:sort src/ --sort-type="alph"
212238` ` `
213239
214240This command will sort the code like this
@@ -225,7 +251,7 @@ use Symfony\OneClass;
225251or by length (two namespaces with same length will be sorted alphabetically)
226252
227253` ` ` bash
228- $ php-formatter use:sort src/ --sort-type="length"
254+ $ php-formatter formatter: use:sort src/ --sort-type="length"
229255` ` `
230256
231257This command will sort the code like this
@@ -243,7 +269,7 @@ You can also define the direction of the sorting. This can be ascending
243269***(default value)***
244270
245271` ` ` bash
246- $ php-formatter use:sort src/ --sort-direction="asc"
272+ $ php-formatter formatter: use:sort src/ --sort-direction="asc"
247273` ` `
248274
249275This command will sort the code like this
@@ -260,7 +286,7 @@ use Symfony\OneClass;
260286or descending
261287
262288` ` ` bash
263- $ php-formatter use:sort src/ --sort-direction="desc"
289+ $ php-formatter formatter: use:sort src/ --sort-direction="desc"
264290` ` `
265291
266292This command will sort the code like this
@@ -273,3 +299,39 @@ use Mmoreram\MySecondClass;
273299use Mmoreram\M yClass;
274300use AnotherBundle\A notherClass;
275301` ` `
302+
303+ # ## Fix all PHP headers
304+
305+ You can define your PHP header in your `.formatter.yml` file an this command
306+ will check and fix that all PHP files have it properly.
307+
308+ * command: `php-formatter formatter:header:fix`
309+ * argument: path
310+ * option: --dry-run [***no value***]
311+
312+ # ### Dry run
313+
314+ You can use this tool just to test the files will be modified, using option
315+ --dry-run
316+
317+ ` ` ` bash
318+ $ php-formatter formatter:header:fix src/ --dry-run
319+ ` ` `
320+
321+ Your PHP Header definition must have this format.
322+
323+ ` ` ` yml
324+ header: |
325+ /**
326+ * This file is part of the php-formatter package
327+ *
328+ * Copyright (c) 2014 Marc Morera
329+ *
330+ * For the full copyright and license information, please view the LICENSE
331+ * file that was distributed with this source code.
332+ *
333+ * Feel free to edit as you please, and have fun.
334+ *
335+ * @author Marc Morera <yuhu@mmoreram.com>
336+ */
337+ ` ` `
0 commit comments