Skip to content

Instantly share code, notes, and snippets.

@zhouyl
Last active December 15, 2015 10:03
Show Gist options
  • Save zhouyl/c284d7c244eea333ce42 to your computer and use it in GitHub Desktop.
Save zhouyl/c284d7c244eea333ce42 to your computer and use it in GitHub Desktop.
Fix PHP Coding Style
#!/bin/bash
### Automatic fixed php coding style ###
bin=/usr/local/bin/php-cs-fixer
# install php-cs-fixer
if [ ! -f $bin ]; then
echo "Preparing to install php-cs-fixer ..."
wget http://cs.sensiolabs.org/get/php-cs-fixer.phar -O $bin
chmod a+x $bin
echo "php-cs-fixer has been successfully installed."
fi
root_dir=$(cd "$(dirname "$0")"; cd ..; pwd)
# require checked php library directories
php_dirs=(app/functions app/config app/controllers app/library app/models app/plugins app/tasks)
for dir in ${php_dirs[@]}; do
$bin fix $root_dir/$dir --level=all --fixers=-psr0
done
echo 'done.'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment