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 # If no PHAN is specified then try to get location from PATH
14 export PHAN
="$(which phan)"
15 if [ ! -f "$PHAN" ]; then
16 echo "The environment variable PHAN must point to the 'phan' file"
17 echo "in a checkout of https://github.com/etsy/phan.git"
18 echo "Or phan must be included in your PATH"
22 export PHAN
="php7.0 $PHAN"
25 if [ -z "$MW_INSTALL_PATH" ]; then
26 # Figure out where mediawiki is based on the location of this script
27 pushd "$(dirname "$0")" > /dev
/null
28 export MW_INSTALL_PATH
="$(git rev-parse --show-toplevel)"
32 # If the first argument doesn't start with a -, then it's a path
33 # to another project (extension, skin, etc.) to analyze
34 if [[ "$1" != "-"* ]]; then
41 # Root directory of project
42 export ROOT
="$(git rev-parse --show-toplevel)"
44 # Go to the root of this git repo
47 export CONFIG_FILE
="$ROOT/tests/phan/config.php"
48 if [ ! -f "$CONFIG_FILE" ]; then
49 echo "Could not find a phan config file to apply in"
54 # Phan's issues directory
55 export ISSUES
="${ROOT}/tests/phan/issues"
58 # Get the current hash of HEAD
59 export REV
="$(git rev-parse HEAD)"
61 # Destination for issues found
62 export RUN
="${ISSUES}/issues-${REV}"
65 # Run the analysis, emitting output to the
68 --project-root-directory "$ROOT" \
69 --config-file "$CONFIG_FILE" \
70 --output "php://stdout" \
72 | php
"$MW_INSTALL_PATH/tests/phan/bin/postprocess-phan.php" "${@}" \
77 # Re-link the latest file
78 rm -f "${ISSUES}/latest"
79 ln -s "${RUN}" "${ISSUES}/latest"
81 # Output any issues that were found