Skip to content

Instantly share code, notes, and snippets.

@JackNoordhuis
Last active January 11, 2020 14:12
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JackNoordhuis/0c67c789d2964fb17915af839714db93 to your computer and use it in GitHub Desktop.
Save JackNoordhuis/0c67c789d2964fb17915af839714db93 to your computer and use it in GitHub Desktop.
Bash script for running phpstan on pocketmine plugins.
#!/bin/sh
PHPSTAN_CONFIG="/pocketmine/phpstan.neon"
ROOT_PATH="$PWD"
VERSION="4"
while getopts "c:p:v" OPTION 2> /dev/null; do
case ${OPTION} in
c)
PHPSTAN_CONFIG="/source/$OPTARG"
;;
p)
ROOT_PATH="$OPTARG"
;;
v)
VERSION="$OPTARG"
;;
\?)
break
;;
esac
done
sh -c "docker run -it -e PHPSTAN_CONFIG=$PHPSTAN_CONFIG -v /$ROOT_PATH:/source nxtlvlsoftware/pmmp-phpstan:$VERSION"
@JackNoordhuis
Copy link
Author

JackNoordhuis commented Jan 11, 2020

Add the script to your shells path and cd into your plugin directory and run phpstan-pm. If you have a phpstan.neon config in your plugin directory you can tell phpstan to use it with the -c option: phpstan -c phpstan.neon.

You can specify the pocketmine API version to run phpstan with by using the -v option: phpstan -v 3.11.3. The latest 3.x.x series is tagged as 3, dev builds of API 4 are available as 4. You can target the latest patch release in a major series as 3.11.

If you use your own phpstan config you will need to tell phpstan to autoload the composer generated pocketmine autoload file:

parameters:
	autoload_files:
		- phar:///pocketmine/PocketMine-MP.phar/vendor/autoload.php

A pocketmine phar is always available at the /pocketmine/PocketMine.phar path in the container.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment