Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feature PHP-CS-Fixer#262 Allow to specify path to .php_cs file using …
…--config-file option (localheinz) This PR was squashed before being merged into the 0.4.x-dev branch (closes PHP-CS-Fixer#262). Discussion ---------- Allow to specify path to .php_cs file using --config-file option This PR adds the possibility to specify the path to the `.php_cs` file using a newly added `--config-file` option. This is very useful if you have a Git `pre-commit` hook similar to the one suggested by [ZF2](https://github.com/zendframework/zf2/blob/master/README-GIT.md#pre-commit-hook-optional), but want to keep the configuration separate from the hook: ```php #!/usr/bin/env php <?php $changes = []; exec( 'git diff --cached --name-status --diff-filter=ACM', $changes ); $exit = 0; array_walk($changes, function ($change) use (&$exit) { if ('D' === substr($change, 0, 1)) { return; } $name = trim(substr( $change, 1 )); $extension = pathinfo( $name, PATHINFO_EXTENSION ); if (!preg_match('/^ph(p|tml)$/', $extension)) { return; } $output = []; $return = 0; exec( sprintf( 'php -l %s', escapeshellarg($name) ), $output, $return ); if (0 != $return) { echo sprintf( 'Failed parsing: %s: ' . PHP_EOL, $name ); echo implode(PHP_EOL, $output) . PHP_EOL; $exit = 1; return; } $output = []; $return = 0; exec( sprintf( 'vendor/bin/php-cs-fixer fix --verbose --config-file=.php_cs %s', escapeshellarg($name) ), $output, $return ); if (0 != $return) { echo sprintf( 'Fixed coding style issues in : %s' . PHP_EOL, $name ); echo implode(PHP_EOL, $output) . PHP_EOL; $exit = 1; return; } }); exit($exit); ``` Fixes PHP-CS-Fixer#251. Commits ------- e4ceb86 Allow to specify path to .php_cs file using --config-file option
- Loading branch information