PHP-CS-Fixer
=============
[PHP Coding Standards Fixer][] 是在不破壞相容性的情況下,將 PHP 的代碼往 [PSR-2][] 的方向修正。
[PHP Coding Standards Fixer]: http://cs.sensiolabs.org/
[PSR-2]: https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-2-coding-style-guide.md
* * * * *
## 安裝方法
以下是基于 Linux 環境的安裝方法:
直接下載 [php-cs-fixer.phar](http://get.sensiolabs.org/php-cs-fixer.phar) 文件
```
wget http://cs.sensiolabs.org/get/php-cs-fixer.phar -O php-cs-fixer
chmod a+x php-cs-fixer
```
放到 `/usr/local/bin` 目錄下
## 使用方法
使用 `fix` 命令修正指定的目錄或文件
```shell
php-cs-fixer fix /path/to/dir
php-cs-fixer fix /path/to/file
```
預設是 PSR-2 以及一些作者自訂的規則,如果要強制只用 PSR-2 的話可以用 `--level=psr2` 。
更多使用說明文檔,請查閱官方 [Github](https://github.com/FriendsOfPHP/PHP-CS-Fixer)
## 專用插件
* [PhpStorm](http://tzfrs.de/2015/01/automatically-format-code-to-match-psr-standards-with-phpstorm)
* [Sublime Text](https://github.com/benmatselby/sublime-phpcs)