Skip to content

Commit

Permalink
feat: add Psalm static analysis
Browse files Browse the repository at this point in the history
  • Loading branch information
COil committed Feb 8, 2025
1 parent eca2f01 commit 9595646
Show file tree
Hide file tree
Showing 7 changed files with 2,504 additions and 206 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/symfony.yml
Original file line number Diff line number Diff line change
Expand Up @@ -122,5 +122,7 @@ jobs:
run: castor lint:php
- name: PHPStan static analysis
run: castor stan
- name: Psalm static analysis
run: castor psalm

# The end. 🙃
7 changes: 5 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ COVERAGE_THRESHOLD = 100
## —— 🎶 The MicroSymfony Makefile 🎶 ——————————————————————————————————————————
help: ## Outputs this help screen
@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/'
.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
.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
.PHONY: version-php version-composer version-symfony version-phpunit version-phpstan version-php-cs-fixer check-requirements le-renew


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

psalm: var/cache/dev/App_KernelDevDebugContainer.xml ## Run the Psalm static analysis
@vendor/bin/psalm

# PHPStan needs the dev/debug cache
var/cache/dev/App_KernelDevDebugContainer.xml:
APP_DEBUG=1 APP_ENV=dev bin/console cache:warmup
Expand All @@ -105,7 +108,7 @@ fix: ## Run all fixers
fix: fix-php

lint: ## Run all linters
lint: stan lint-php lint-container lint-twig lint-yaml
lint: stan psalm lint-php lint-container lint-twig lint-yaml

ci: ## Run CI locally
ci: coverage warmup lint
Expand Down
15 changes: 15 additions & 0 deletions castor.php
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,21 @@ function stan(): int
return exit_code('vendor/bin/phpstan analyse -c phpstan.neon --memory-limit 1G -vv');
}

#[AsTask(namespace: 'lint', description: 'Run Psalm', aliases: ['psalm'])]
function psalm(): int
{
title('lint:psalm');

if (!file_exists('var/cache/dev/App_KernelDevDebugContainer.xml')) {
io()->note('Psalm needs the dev/debug cache. Generating it...');
run('bin/console cache:warmup',
context: context()->withEnvironment(['APP_ENV' => 'dev', 'APP_DEBUG' => 1])
);
}

return exit_code('vendor/bin/psalm');
}

#[AsTask(name: 'php', namespace: 'fix', description: 'Fix PHP files with php-cs-fixer (ignore PHP 8.3 warnings)', aliases: ['fix-php'])]
function fix_php(): int
{
Expand Down
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
"phpstan/extension-installer": "^1.3",
"phpstan/phpstan-symfony": "^2.0",
"phpunit/phpunit": "^11.0",
"psalm/plugin-symfony": "^5.2",
"roave/security-advisories": "dev-latest",
"symfony/browser-kit": "~7.2.0",
"symfony/css-selector": "~7.2.0",
Expand Down
Loading

0 comments on commit 9595646

Please sign in to comment.