Merge "Add configuration for running etsy/phan against core"
[lhc/web/wiklou.git] / tests / phan / bin / phan
1 #!/bin/sh
2
3 # Note that this isn't loaded in via composer because then composer can
4 # only be run with php7.0
5 if [ ! -f "$PHAN" ]; then
6 echo "The environment variable PHAN must point to the 'phan' file"
7 echo "in a checkout of https://github.com/etsy/phan.git"
8 exit 1
9 fi
10
11 cd "$(dirname "$0")"
12
13 # Root directory of project
14 export ROOT="$(git rev-parse --show-toplevel)"
15
16 # Phan's issues directory
17 export ISSUES="${ROOT}/tests/phan/issues"
18
19 # Go to the root of this git repo
20 cd "$ROOT"
21
22 # Get the current hash of HEAD
23 export REV="$(git rev-parse HEAD)"
24
25 # Destination for issues found
26 export RUN="${ISSUES}/issues-${REV}"
27
28 # Run the analysis, emitting output to the
29 # issues file.
30 php7.0 $PHAN \
31 --project-root-directory "$ROOT" \
32 --config-file "$ROOT/tests/phan/config.php" \
33 --output "$ROOT/tests/phan/issues/issues-${REV}" \
34 -j 4
35
36 # Re-link the latest directory
37 rm -f "${ISSUES}/latest"
38 ln -s "${RUN}" "${ISSUES}/latest"
39
40 # Output any issues that were found
41 cat "${RUN}"
42
43 if [ $(wc -l < ${RUN}) -ne 0 ]; then
44 exit 1
45 fi