Browse Source

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

chaotic
parent
commit
a6d5752748
Signed by: diogo <mail@diogo.site> GPG Key ID: 18D2D35001FBFAB0
4 changed files with 24 additions and 5 deletions
  1. +2
    -2
      .dir-locals.el
  2. +1
    -2
      Makefile
  3. +11
    -0
      bin/phpstan
  4. +10
    -1
      docker/tooling/phpstan.sh

+ 2
- 2
.dir-locals.el 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"))
)

+ 1
- 2
Makefile 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
- 0
bin/phpstan 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 "$@"

+ 10
- 1
docker/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/*

Loading…
Cancel
Save