1- PHP Formatter
2- =============
1+ # PHP Formatter
2+
33[ ![ 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 )
74
85This PHP formatter aims to provide you some bulk actions for you PHP projects to
96ensure 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 ) .
188
199## Install
2010
@@ -51,14 +41,15 @@ $ cp build/php-formatter.phar /usr/local/bin/php-formatter
5141
5242### Compile
5343
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.
5547
5648``` bash
5749$ git clone git@github.com:mmoreram/php-formatter.git
5850$ cd php-formatter
5951$ composer update
60- $ php bin/compile
61- $ sudo chmod +x build/php-formatter.phar
52+ $ box build -v
6253$ build/php-formatter.phar
6354```
6455
@@ -136,8 +127,9 @@ Available commands:
136127 help Displays help for a command
137128 list Lists commands
138129formatter
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
141133` ` `
142134
143135# ## Sort all Use Statements
@@ -148,21 +140,13 @@ process.
148140
149141* command: `php-formatter formatter:use:sort`
150142* argument: path
143+ * option: --exclude [***multiple***]
151144* option: --group [***multiple***]
152145* option: --group-type=***one***|***each***
153146* option: --sort-type=***alph***|***length***
154147* option: --sort-direction=***asc***|***desc***
155148* option: --dry-run [***no value***]
156149
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-
166150# ### Group
167151
168152You 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.
320304
321305* command: `php-formatter formatter:header:fix`
322306* argument: path
307+ * option: --exclude [***multiple***]
323308* option: --dry-run [***no value***]
324309
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 <yuhu@mmoreram.com>
349- */
350- ` ` `
351-
352310# ## Fix all strict declarations
353311
354312In 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.
359317
360318* command: `php-formatter formatter:strict:fix`
361319* argument: path
320+ * option: --exclude [***multiple***]
362321* option: --dry-run [***no value***]
363322
364323You can have three values here. If you define a boolean, then each file found
@@ -373,4 +332,31 @@ removed.
373332
374333` ` ` yml
375334strict: '~'
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