3 # mediawiki-vagrant installs dont have realpath by default
4 if ! which realpath
> /dev
/null
; then
6 php
-r "echo realpath('$*');"
10 if hash php7.0
2>/dev
/null
; then
16 # Note that this isn't loaded in via composer because then composer can
17 # only be run with php7.0
18 if [ ! -f "$PHAN" ]; then
19 # If no PHAN is specified then try to get location from PATH
20 export PHAN
="$(which phan)"
21 if [ ! -f "$PHAN" ]; then
22 echo "The environment variable PHAN must point to the 'phan' file"
23 echo "in a checkout of https://github.com/etsy/phan.git"
24 echo "Or phan must be included in your PATH"
28 export PHAN
="$PHP $PHAN"
31 if [ -z "$MW_INSTALL_PATH" ]; then
32 # Figure out where mediawiki is based on the location of this script
33 pushd "$(dirname "$0")" > /dev
/null
34 export MW_INSTALL_PATH
="$(git rev-parse --show-toplevel)"
38 # If the first argument doesn't start with a -, then it's a path
39 # to another project (extension, skin, etc.) to analyze
40 if [[ -n "$1" && "$1" != "-"* ]]; then
47 # Root directory of project
48 export ROOT
="$(git rev-parse --show-toplevel)"
50 # Go to the root of this git repo
53 export CONFIG_FILE
="$ROOT/tests/phan/config.php"
54 if [ ! -f "$CONFIG_FILE" ]; then
55 echo "Could not find a phan config file to apply in"
60 # Phan's issues directory
61 export ISSUES
="${ROOT}/tests/phan/issues"
64 # Get the current hash of HEAD
65 export REV
="$(git rev-parse HEAD)"
67 # Destination for issues found
68 export RUN
="${ISSUES}/issues-${REV}"
71 # Run the analysis, emitting output to the
74 --project-root-directory "$ROOT" \
75 --config-file "$CONFIG_FILE" \
76 --output "php://stdout" \
78 | php
"$MW_INSTALL_PATH/tests/phan/bin/postprocess-phan.php" "${@}" \
83 # Re-link the latest file
84 rm -f "${ISSUES}/latest"
85 ln -s "${RUN}" "${ISSUES}/latest"
87 # Output any issues that were found