diff --git a/.travis.yml b/.travis.yml index 6ba9c67e..f8b8bd40 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,12 +7,13 @@ php: - 7.0 before_install: - - wget http://get.sensiolabs.org/php-cs-fixer.phar + - export PATH="$PATH:$HOME/.composer/vendor/bin" + - composer global require friendsofphp/php-cs-fixer:1.* before_script: - chmod +x scripts/tests/syntax.sh - chmod +x scripts/tests/codestyle.sh - + script: - scripts/tests/syntax.sh - - scripts/tests/codestyle.sh \ No newline at end of file + - scripts/tests/codestyle.sh diff --git a/lib/class/art.class.php b/lib/class/art.class.php index 44bd429a..cf896ef9 100644 --- a/lib/class/art.class.php +++ b/lib/class/art.class.php @@ -1801,4 +1801,3 @@ class Art extends database_object return true; } } // Art - diff --git a/lib/class/catalog.class.php b/lib/class/catalog.class.php index 4c9e49e3..224b75db 100644 --- a/lib/class/catalog.class.php +++ b/lib/class/catalog.class.php @@ -1233,7 +1233,9 @@ abstract class Catalog extends database_object $art->save_thumb($thumb['thumb'], $thumb['thumb_mime'], $size); } } - if ($inserted) break; + if ($inserted) { + break; + } } else { debug_event('gather_art', 'Image less than 5 chars, not inserting', 3); } diff --git a/lib/class/core.class.php b/lib/class/core.class.php index c80d8f76..e7d52815 100644 --- a/lib/class/core.class.php +++ b/lib/class/core.class.php @@ -397,4 +397,3 @@ class Core return $tmp_dir; } } // Core - diff --git a/scripts/hooks/pre-commit b/scripts/hooks/pre-commit index a54e65c0..a03b4196 100755 --- a/scripts/hooks/pre-commit +++ b/scripts/hooks/pre-commit @@ -10,6 +10,10 @@ then elif hash php-cs-fixer then PHPCSFIXER="php-cs-fixer" +else + echo -e "\e[1;31mPlease install or download latest stable php-cs-fixer\e[00m"; + echo -e "\e[1;31mhttp://cs.sensiolabs.org/\e[00m"; + exit 1 fi if git rev-parse --verify HEAD >/dev/null 2>&1 @@ -20,7 +24,7 @@ else against=4b825dc642cb6eb9a060e54bf8d69288fbee4904 fi -FIXERS='indentation,linefeed,trailing_spaces,short_tag,braces,controls_spaces,eof_ending,visibility,align_equals,concat_with_spaces,elseif,line_after_namespace,lowercase_constants' +FIXERS='indentation,linefeed,trailing_spaces,short_tag,braces,controls_spaces,eof_ending,visibility,align_equals,concat_with_spaces,elseif,line_after_namespace,lowercase_constants,encoding' ST=0 # Global exit status @@ -28,7 +32,7 @@ ST=0 # Global exit status for file in $(git diff-index --name-only $against); do echo -n "testing $file..." - FIXEROUT=$(php-cs-fixer fix --dry-run -v --fixers=$FIXERS "$file" | grep -P '\d\)' | sed -r "s~^.*?${file} ~~"; exit ${PIPESTATUS[0]}) + FIXEROUT=$($PHPCSFIXER fix --dry-run --diff -v --fixers=$FIXERS "$file" | grep -P '\d\)' | sed -r "s~^.*?${file} ~~"; exit ${PIPESTATUS[0]}) FIXERST=$? PARSEROUT=$(php --syntax-check "$file" 2>&1 | egrep -v 'No syntax errors|Errors parsing'; exit ${PIPESTATUS[0]}) @@ -40,7 +44,7 @@ for file in $(git diff-index --name-only $against); do elif [ $PARSERST != 0 ]; then echo $PARSEROUT else - echo "OK " + echo -e "\e[0;32mOK\e[00m "; fi ST=$(($ST | $FIXERST | $PARSERST)) done diff --git a/scripts/tests/codestyle.sh b/scripts/tests/codestyle.sh index 1ec9e53a..7e73a6d5 100644 --- a/scripts/tests/codestyle.sh +++ b/scripts/tests/codestyle.sh @@ -7,21 +7,21 @@ elif hash php-cs-fixer then PHPCSFIXER="php-cs-fixer" else - echo -e "\e[1;31mPlease install or download php-cs-fixer\e[00m"; + echo -e "\e[1;31mPlease install or download latest stable php-cs-fixer\e[00m"; echo -e "\e[1;31mhttp://cs.sensiolabs.org/\e[00m"; exit 1 fi PHPCSFIXERARGS="fix -v --fixers=" # Mandatory fix -FIXERS1="indentation,linefeed,trailing_spaces,short_tag,braces,controls_spaces,visibility,align_equals,concat_with_spaces,elseif,line_after_namespace,lowercase_constants" +FIXERS1="indentation,linefeed,trailing_spaces,short_tag,braces,controls_spaces,eof_ending,visibility,align_equals,concat_with_spaces,elseif,line_after_namespace,lowercase_constants,encoding" # Optionnal fix & false positive #FIXERS2="visibility" EXIT=0 echo -e "\e[1;34mChecking mandatory formatting/coding standards\e[00m" -$PHPCSFIXER $PHPCSFIXERARGS$FIXERS1 --dry-run . +$PHPCSFIXER $PHPCSFIXERARGS$FIXERS1 --dry-run --diff . rc=$? if [[ $rc == 0 ]] then