11#! /bin/sh
22#
3- # Installation
4- # ------------
3+ # == Installation
54#
65# Create a Git hooks directory:
76#
@@ -26,39 +25,23 @@ unset CDPATH
2625IFS='
2726'
2827
29- run_php_cs_fixer () {
30- php_cs_fixer_bin=
31-
32- # Find the PHP Coding Standards fixer script and configuration.
33- for base_dir in . ./laravel; do
34- php_cs_fixer_bin_candidate=" $base_dir /vendor/bin/php-cs-fixer"
35-
36- if test -f " $php_cs_fixer_bin_candidate " ; then
37- php_cs_fixer_bin=" $php_cs_fixer_bin_candidate "
38-
39- # Local override.
40- if test -f " $base_dir /.php-cs-fixer.php" ; then
41- php_cs_fixer_config=" $base_dir /.php-cs-fixer.php"
42-
43- # Default.
44- elif test -f " $base_dir /.php-cs-fixer.dist.php" ; then
45- php_cs_fixer_config=" $base_dir /.php-cs-fixer.dist.php"
46-
47- # Deprecated version 2 local override.
48- elif test -f " $base_dir /.php_cs" ; then
49- php_cs_fixer_config=" $base_dir /.php_cs"
50-
51- # Deprecated version 2 default.
52- elif test -f " $base_dir /.php_cs.dist" ; then
53- php_cs_fixer_config=" $base_dir /.php_cs.dist"
54- fi
55-
56- break
28+ php_cs_fixer_cfg () {
29+ for candidate in .php-cs-fixer.php .php-cs-fixer.dist.php .php_cs .php_cs.dist; do
30+ if test -f " $1 /$candidate " ; then
31+ echo " $1 /$candidate "
32+ return
5733 fi
5834 done
35+ }
36+
37+ run_php_cs_fixer () {
38+ php_cs_fixer_bin=./vendor/bin/php-cs-fixer
39+ if test ! -f " $php_cs_fixer_bin " ; then
40+ return
41+ fi
5942
60- # Only run if a PHP Coding Standards fixer could be found.
61- if test -z " $php_cs_fixer_bin " ; then
43+ php_cs_fixer_cfg= " $( php_cs_fixer_cfg . ) "
44+ if test -z " $php_cs_fixer_cfg " ; then
6245 return
6346 fi
6447
@@ -77,7 +60,7 @@ run_php_cs_fixer() {
7760 echo >&2 " \033[0;33mCoding guidelines pre-commit check failed.\033[1;0m"
7861 echo >&2 " \033[0;33mRunning check again in verbose mode ...\033[1;0m"
7962
80- " $php_cs_fixer_bin " fix --config=" $php_cs_fixer_config " \
63+ " $php_cs_fixer_bin " fix --config=" $php_cs_fixer_cfg " \
8164 -vvv \
8265 --diff \
8366 --dry-run \
@@ -92,7 +75,7 @@ run_php_cs_fixer() {
9275 # again in verbose mode to provide more information about which rules and
9376 # which files are failing the check.
9477 " $php_cs_fixer_bin " fix \
95- --config=" $php_cs_fixer_config " \
78+ --config=" $php_cs_fixer_cfg " \
9679 -q \
9780 --dry-run \
9881 --stop-on-violation \
0 commit comments