phpcs.sh 848 Bytes
Newer Older
Bertrand Gauthier's avatar
Bertrand Gauthier committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!/usr/bin/env bash

[[ -z $1 ]] && echo "Veuillez spécifier la version de PHP désirée (ex: 7.1)." && exit 1

DIR=$(cd `dirname $0` && pwd)
DIRNAME=$(basename ${DIR})

cd ${DIR}/..

version=$1

# conversion de la version spécifiée au format PHP_VERSION_ID, ex: "7.2" devien "70200"
a=(${version//./ })
PHP_VERSION_ID=$((a[0]*10000+a[1]*100+a[2]))

phpcs="./vendor/bin/phpcs"
libdir="./vendor/unicaen"
reportpath="/tmp/unicaen-${version}.log"

echo "" > ${reportpath}

for path in ${libdir}/*
do
    dirname=$(basename -- "$path")
    echo "Processing '${path}' against PHP version ${version} (PHP_VERSION_ID=${PHP_VERSION_ID})"
    ${phpcs} \
        -p \
         --standard=PHPCompatibility \
        --runtime-set php_version ${PHP_VERSION_ID} \
        --report-full ${reportpath} \
        ${path}
done

echo "Done. See '${reportpath}'."