Skip to content

Instantly share code, notes, and snippets.

@fesor
Last active March 16, 2022 06:12
Show Gist options
  • Star 27 You must be signed in to star a gist
  • Fork 8 You must be signed in to fork a gist
  • Save fesor/1043aec3f1aeac7d801c270e0fba36cd to your computer and use it in GitHub Desktop.
Save fesor/1043aec3f1aeac7d801c270e0fba36cd to your computer and use it in GitHub Desktop.
php-cs-fixer pre-commit hook
#!/usr/bin/env bash
echo "php-cs-fixer pre commit hook start"
PHP_CS_FIXER="bin/php-cs-fixer"
PHP_CS_CONFIG=".php_cs"
CHANGED_FILES=$(git diff --cached --name-only --diff-filter=ACM -- '*.php')
if [ -n "$CHANGED_FILES" ]; then
$PHP_CS_FIXER fix --config "$PHP_CS_CONFIG" $CHANGED_FILES;
git add $CHANGED_FILES;
fi
echo "php-cs-fixer pre commit hook finish"
@sdanilishin
Copy link

Good idea, thanks 👍

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