3 # mediawiki-vagrant installs dont have realpath by default
4 if ! which realpath
> /dev
/null
; then
6 php
-r "echo realpath('$*');"
10 # Note that this isn't loaded in via composer because then composer can
11 # only be run with php7.0
12 if [ ! -f "$PHAN" ]; then
13 echo "The environment variable PHAN must point to the 'phan' file"
14 echo "in a checkout of https://github.com/etsy/phan.git"
18 if [ -z "$MW_INSTALL_PATH" ]; then
19 # Figure out where mediawiki is based on the location of this script
20 pushd "$(dirname "$0")" > /dev
/null
21 export MW_INSTALL_PATH
="$(git rev-parse --show-toplevel)"
25 # If the first argument doesn't start with a -, then it's a path
26 # to another project (extension, skin, etc.) to analyze
27 if [[ "$1" != "-"* ]]; then
34 # Root directory of project
35 export ROOT
="$(git rev-parse --show-toplevel)"
37 # Go to the root of this git repo
40 export CONFIG_FILE
="$ROOT/tests/phan/config.php"
41 if [ ! -f "$CONFIG_FILE" ]; then
42 echo "Could not find a phan config file to apply in"
47 # Phan's issues directory
48 export ISSUES
="${ROOT}/tests/phan/issues"
51 # Get the current hash of HEAD
52 export REV
="$(git rev-parse HEAD)"
54 # Destination for issues found
55 export RUN
="${ISSUES}/issues-${REV}"
58 # Run the analysis, emitting output to the
61 --project-root-directory "$ROOT" \
62 --config-file "$CONFIG_FILE" \
63 --output "php://stdout" \
65 | php
"$MW_INSTALL_PATH/tests/phan/bin/postprocess-phan.php" "${@}" \
70 # Re-link the latest file
71 rm -f "${ISSUES}/latest"
72 ln -s "${RUN}" "${ISSUES}/latest"
74 # Output any issues that were found