Skip to content

Commit ab010e0

Browse files
committed
feat: add Psalm static analysis
1 parent 54da85c commit ab010e0

File tree

7 files changed

+2492
-206
lines changed

7 files changed

+2492
-206
lines changed

.github/workflows/symfony.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,5 +122,7 @@ jobs:
122122
run: castor lint:php
123123
- name: PHPStan static analysis
124124
run: castor stan
125+
- name: Psalm static analysis
126+
run: castor psalm
125127

126128
# The end. 🙃

Makefile

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ COVERAGE_THRESHOLD = 100
1010
## —— 🎶 The MicroSymfony Makefile 🎶 ——————————————————————————————————————————
1111
help: ## Outputs this help screen
1212
@grep -E '(^[a-zA-Z0-9_-]+:.*?##.*$$)|(^##)' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}{printf "\033[32m%-30s\033[0m %s\n", $$1, $$2}' | sed -e 's/\[32m##/[33m/'
13-
.PHONY: help start stop go-prod go-dev purge test test-api test-e2e test-functional test-integration test-unit coverage cov-report stan fix-php lint-php lint-container lint-twig lint-yaml fix lint ci deploy
13+
.PHONY: help start stop go-prod go-dev purge test test-api test-e2e test-functional test-integration test-unit coverage cov-report stan psalm fix-php lint-php lint-container lint-twig lint-yaml fix lint ci deploy
1414
.PHONY: version-php version-composer version-symfony version-phpunit version-phpstan version-php-cs-fixer check-requirements le-renew
1515

1616

@@ -81,6 +81,9 @@ cov-report: var/coverage/index.html ## Open the PHPUnit code coverage report (va
8181
stan: var/cache/dev/App_KernelDevDebugContainer.xml ## Run the PHPStan static analysis
8282
@vendor/bin/phpstan analyse -c phpstan.neon --memory-limit 1G -vv
8383

84+
psalm: var/cache/dev/App_KernelDevDebugContainer.xml ## Run the Psalm static analysis
85+
@vendor/bin/psalm
86+
8487
# PHPStan needs the dev/debug cache
8588
var/cache/dev/App_KernelDevDebugContainer.xml:
8689
APP_DEBUG=1 APP_ENV=dev bin/console cache:warmup
@@ -105,7 +108,7 @@ fix: ## Run all fixers
105108
fix: fix-php
106109

107110
lint: ## Run all linters
108-
lint: stan lint-php lint-container lint-twig lint-yaml
111+
lint: stan psalm lint-php lint-container lint-twig lint-yaml
109112

110113
ci: ## Run CI locally
111114
ci: coverage warmup lint

castor.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,21 @@ function stan(): int
209209
return exit_code('vendor/bin/phpstan analyse -c phpstan.neon --memory-limit 1G -vv');
210210
}
211211

212+
#[AsTask(namespace: 'lint', description: 'Run Psalm', aliases: ['psalm'])]
213+
function psalm(): int
214+
{
215+
title('lint:psalm');
216+
217+
if (!file_exists('var/cache/dev/App_KernelDevDebugContainer.xml')) {
218+
io()->note('Psalm needs the dev/debug cache. Generating it...');
219+
run('bin/console cache:warmup',
220+
context: context()->withEnvironment(['APP_ENV' => 'dev', 'APP_DEBUG' => 1])
221+
);
222+
}
223+
224+
return exit_code('vendor/bin/psalm');
225+
}
226+
212227
#[AsTask(name: 'php', namespace: 'fix', description: 'Fix PHP files with php-cs-fixer (ignore PHP 8.3 warnings)', aliases: ['fix-php'])]
213228
function fix_php(): int
214229
{

composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@
5454
"phpstan/extension-installer": "^1.3",
5555
"phpstan/phpstan-symfony": "^2.0",
5656
"phpunit/phpunit": "^11.0",
57+
"psalm/plugin-symfony": "^5.2",
5758
"roave/security-advisories": "dev-latest",
5859
"symfony/browser-kit": "~7.2.0",
5960
"symfony/css-selector": "~7.2.0",

0 commit comments

Comments
 (0)