Last active
August 29, 2015 14:05
-
-
Save s7anley/9d9cf0152ee1431715a6 to your computer and use it in GitHub Desktop.
Pre commit php-cs-fixer
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
PROJECTROOT="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )/" | |
FIXER=php-cs-fixer.phar | |
if [ ! -e ${PROJECTROOT}${FIXER} ]; then | |
echo "PHP-CS-Fixer not available, downloading to ${PROJECTROOT}${FIXER}..." | |
curl -s http://cs.sensiolabs.org/get/$FIXER > ${PROJECTROOT}${FIXER} | |
echo "" | |
fi | |
git diff --cached --name-only | while read LINE ; do | |
FILENAME=$(basename "$LINE") | |
EXTENSION="${FILENAME##*.}" | |
if [ "$EXTENSION" == "php" ]; then | |
php ${PROJECTROOT}${FIXER} fix $LINE --level=all --diff --fixers=-phpdoc_params | |
git add $LINE; | |
fi; | |
done; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment