From 27e911f02c9abc72ea6e16f7f3ef466563616568 Mon Sep 17 00:00:00 2001 From: Michael Strelan Date: Mon, 3 Feb 2025 14:53:09 +1000 Subject: [PATCH] Add support for running phpstan and generating the baseline (#37) * Autoload phpstan rules * Makefile targets * Fix work dir * Readme --- Makefile | 7 +++++++ README.md | 2 ++ composer.json | 5 +++++ 3 files changed, 14 insertions(+) diff --git a/Makefile b/Makefile index 8ca0536..11d4901 100644 --- a/Makefile +++ b/Makefile @@ -8,6 +8,7 @@ endif ifneq ("$(shell whoami)", "skpr") EXEC=$(DOCKER_COMPOSE) exec -T php-cli + EXEC_APP=$(DOCKER_COMPOSE) exec -w /data/app -T php-cli endif DRUSH=$(EXEC) ./bin/drush @@ -45,6 +46,12 @@ login: switch: $(GIT_SWITCH) $(BRANCH) +phpstan: + $(EXEC_APP) /data/bin/phpstan --configuration=./core/phpstan.neon.dist --memory-limit=1G + +phpstan-baseline: + $(EXEC_APP) /data/bin/phpstan --configuration=./core/phpstan.neon.dist --generate-baseline=./core/.phpstan-baseline.php --memory-limit=1G + 9.3: php8.0 $(GIT_SWITCH) 9.3.x make clean diff --git a/README.md b/README.md index 44b316d..019339a 100644 --- a/README.md +++ b/README.md @@ -51,6 +51,8 @@ Make commands should be executed on the host machine. * `umami` - installs Drupal with the demo_umami profile * `login` - gets a one-time login link * `switch` - switches branch, e.g. `make BRANCH=9.3 switch` +* `phpstan` - runs phpstan for core +* `phpstan-baseline` - generates phpstan baseline for core * `10.2|10.3|10.4|10.5|11.0|11.1|11.x` - provides a clean environment with the specified Drupal version * `php8.1|php8.2|php8.3` - starts the stack with the specified php version diff --git a/composer.json b/composer.json index e20d8f3..5d2ea1c 100644 --- a/composer.json +++ b/composer.json @@ -76,6 +76,11 @@ "mstrelan\\DrupalContrib\\": "src/" } }, + "autoload-dev": { + "psr-4": { + "Drupal\\PHPStan\\Rules\\": "app/core/tests/PHPStan/Rules" + } + }, "extra": { "drupal-scaffold": { "locations": {