See https://github.com/phan/phan/wiki/How-To-Use-Stubs
This uses tool/make_stubs -e $EXTENSION_NAME from a Phan installation.
Clone phan and run composer install inside of phan directory.
export PHAN_CHECKOUT_PATH=/path/to/phan
./make_stubs.shfor stub generation.