[TOOLS][PHPStan] Make a standalone phpstan executable, which executes inside the docker container

This commit is contained in:
Hugo Sales 2021-10-21 15:11:00 +01:00 committed by Diogo Peralta Cordeiro
parent 299e893ca9
commit a6d5752748
Signed by: diogo
GPG Key ID: 18D2D35001FBFAB0
4 changed files with 24 additions and 5 deletions

View File

@ -1,3 +1,3 @@
((nil . ((php-project-root . auto)
(phpstan-config-file . (root . "phpstan.neon"))
(phpstan-memory-limit . "2G"))))
(phpstan-executable . (root . "bin/phpstan"))
)

View File

@ -2,7 +2,6 @@ DIR=$(strip $(notdir $(CURDIR))) # Seems a bit hack-ish, but `basename` works di
translate-container-name = $$(if docker container inspect $(1) > /dev/null 2>&1; then echo $(1); else echo $(1) | sed 'y/_/-/' ; fi)
.PHONY:
@if ! docker info > /dev/null; then echo "Docker does not seem to be running"; exit 1; fi
@ -37,7 +36,7 @@ doc-check:
bin/php-doc-check src components plugins
phpstan: tooling-docker
docker exec $(call translate-container-name,tooling_php_1) /var/tooling/phpstan.sh
bin/phpstan
stop-tooling: .PHONY
cd docker/tooling && docker-compose down

11
bin/phpstan Executable file
View File

@ -0,0 +1,11 @@
#!/bin/sh
translate_container_name () {
if docker container inspect "$1" > /dev/null 2>&1; then
echo "$1"
else
echo "$1" | sed 'y/_/-/'
fi
}
docker exec "$(translate_container_name tooling_php_1)" /var/tooling/phpstan.sh "$@"

View File

@ -2,6 +2,15 @@
cd /var/www/social || exit 1
ARGS=$(echo "$*" | sed 's#\(/[^/]\+\)*/phpstan\.neon#phpstan.neon#') # Remove absolute path to config file
rm -rf /var/www/social/var/cache/*
PHPSTAN_BOOT_KERNEL=1 vendor/bin/phpstan --ansi --no-interaction --memory-limit=2G analyse
if [ "$#" -eq 0 ]; then
PHPSTAN_BOOT_KERNEL=1 vendor/bin/phpstan --ansi --no-interaction --memory-limit=2G analyse
else
PHPSTAN_BOOT_KERNEL=1 vendor/bin/phpstan $ARGS
fi
rm -rf /var/www/social/var/cache/*