Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Laravel PHPStan Runner
#!/usr/bin/env bash
readonly DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )";
cd $DIR;
set -e
set -u
set -o pipefail
standardIFS="$IFS"
IFS=$'\n\t'
echo "
===========================================
$(hostname) $0 $@
===========================================
"
readonly projectRoot=$(realpath $DIR/../../);
readonly logPath="$projectRoot/storage/logs/static-analysis.log"
cd $projectRoot
if [[ ! -f ./vendor/bin/phpstan ]]
then
composer require --dev phpstan/phpstan
fi
echo "generate IDE helper"
php artisan ide-helper:generate
sed -i 's#exit("This file should not be included, only analyzed by your IDE");#if\(class_exists\(\\\PHPStan\\\Analyser\\\Analyser::class, false\)\) exit\("This file should not be included, only analyzed by your IDE"\);#g' _ide_helper.php
echo "done"
echo "run analysis"
./vendor/bin/phpstan \
analyse \
--autoload-file=_ide_helper.php \
--level 7 \
app \
| tee $logPath;
echo "Finished, log output written to $logPath";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment