Skip to content

Commit 84639e1

Browse files
committed
Merge branch 'master' of github.com:talyian/pre-commit-php
2 parents 4a8c71c + 1ea3170 commit 84639e1

1 file changed

Lines changed: 11 additions & 12 deletions

File tree

pre_commit_hooks/php-cs.sh

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -26,19 +26,18 @@ phpcs_command="php $phpcs_local_exec"
2626
# Check vendor/bin/phpunit
2727
phpcs_vendor_command="vendor/bin/phpcs"
2828
phpcs_global_command="phpcs"
29+
2930
if [ -f "$phpcs_vendor_command" ]; then
30-
phpcs_command=$phpcs_vendor_command
31+
phpcs_command=$phpcs_vendor_command
32+
elif type -P 'phpcs'; then
33+
phpcs_command='phpcs'
34+
elif type -P 'phpcs.phar'; then
35+
phpcs_command='phpcs.phar'
36+
elif [ -f "$phpcs_local_exec" ]; then
37+
phpcs_command=$phpcs_command
3138
else
32-
if hash phpcs 2>/dev/null; then
33-
phpcs_command=$phpcs_global_command
34-
else
35-
if [ -f "$phpcs_local_exec" ]; then
36-
phpcs_command=$phpcs_command
37-
else
38-
echo "No valid PHP Codesniffer executable found! Please have one available as either $phpcs_vendor_command, $phpcs_global_command or $phpcs_local_exec"
39-
exit 1
40-
fi
41-
fi
39+
echo "No valid PHP Codesniffer executable found! Please have one available as either $phpcs_vendor_command, $phpcs_global_command or $phpcs_local_exec"
40+
exit 1
4241
fi
4342

4443
phpcs_files_to_check="${@:2}"
@@ -57,4 +56,4 @@ then
5756
exit 1
5857
fi
5958

60-
exit 0
59+
exit 0

0 commit comments

Comments
 (0)