Skip to content

Instantly share code, notes, and snippets.

@dave1010
Created July 22, 2015 09:59
Show Gist options
  • Save dave1010/6059d3626cd529e11420 to your computer and use it in GitHub Desktop.
Save dave1010/6059d3626cd529e11420 to your computer and use it in GitHub Desktop.
#!/bin/bash
# stolen from template file
if git rev-parse --verify HEAD > /dev/null
then
against=HEAD
else
# Initial commit: diff against an empty tree object
against=4b825dc642cb6eb9a060e54bf8d69288fbee4904
fi
# this is the magic:
# retrieve all files in staging area that are added, modified or renamed
# but no deletions etc
FILES=$(git diff-index --name-only --cached --diff-filter=ACMR $against -- | grep php$)
if [ "$FILES" == "" ]; then
exit 0
fi
echo -n "PHP CS Fixer "
for FILE in $FILES
do
php vendor/fabpot/php-cs-fixer/php-cs-fixer fix $FILE --config=sf23 --quiet
echo -n .
done
echo " Done"
@chrisnx
Copy link

chrisnx commented Jul 22, 2015

You'll need to have done this:
composer require fabpot/php-cs-fixer

@rossey
Copy link

rossey commented Jul 22, 2015

And it's currently set to Symfony Framework v2.3 standards/glitter

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment