#!/usr/bin/env bash
dir=`dirname realpath $0`
# Check php syntax
$dir/check-php-syntax
if [ $? -ne 0 ]; then
message="Aborting commit due to files with syntax errors."
echo -e "\033[0;31m$message\033[0;39m" >&2
exit 1
fi
# Run php-cs-fixer
$dir/run-php-cs-fixer
if [ $? -ne 0 ]; then
exit 1
fi
#!/usr/bin/env bash
root=$(git rev-parse --show-toplevel)
files=($(git diff --name-only --cached | egrep '\.php$' | sed -e "s|^|$root/|"))
for file in "${files[@]}"; do
if [ -f "$file" ]; then
/usr/bin/php -l "$file" > /dev/null
if [ $? -ne 0 ]; then
exit 1
fi
fi
done
#!/usr/bin/env bash
root=($(git rev-parse --show-toplevel |sed -e "s|/usr/home|/home|"))
files=($(git diff --name-only --cached | egrep "\.php$" | sed -e "s|^|$root/|"))
for file in "${files[@]}"; do
if [ -f "$file" ]; then
/usr/bin/php ~/local/bin/php-cs-fixer fix $file --diff --verbose --dry-run
if [ $? -ne 0 ]; then
echo -------------------------------------------------------------------
echo "# Run this command if you want to fix php-cs(PHP-Coding-Standards)."
echo "/usr/bin/php ~/local/bin/php-cs-fixer fix $file --diff --verbose"
echo "# Or add -n(--no-verify) option on commit, if you do NOT want to fix it."
echo "git commit -v -n $file"
echo -------------------------------------------------------------------
exit 1
fi
fi
done
chmod 755 pre-commit
chmod 755 check-syntax
chmod 755 php-cs-fixer