Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/symfony.yml
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,8 @@ jobs:
run: castor ci:lint-php
- name: PHPStan static analysis
run: castor stan
- name: Psalm static analysis
run: castor psalm
- name: Lint JS and CSS files
run: castor ci:lint-js-css

Expand Down
5 changes: 4 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,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 Down Expand Up @@ -121,7 +124,7 @@ fix: ## Run all fixers
fix: fix-php fix-js-css

lint: ## Run all linters
lint: stan lint-php lint-doctrine lint-js-css lint-container lint-twig
lint: stan psalm lint-php lint-doctrine lint-js-css lint-container lint-twig

ci: ## Run CI locally
ci: coverage warmup lint
Expand Down
38 changes: 26 additions & 12 deletions castor.php
Original file line number Diff line number Diff line change
Expand Up @@ -222,21 +222,34 @@ function cov_report(): int
return success(exit_code(sprintf('open %s', $coverageFile)));
}

#[AsTask(namespace: 'lint', description: 'Run PHPStan', aliases: ['stan'])]
function stan(): int
function warmupDevCache(): void
{
title('lint:stan');

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

#[AsTask(namespace: 'lint', description: 'Run PHPStan', aliases: ['stan'])]
function stan(): int
{
title('lint:stan');
warmupDevCache();

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');
warmupDevCache();

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

#[AsTask(name: 'php', namespace: 'fix', description: 'Fix PHP files with php-cs-fixer (ignore PHP 8.4 warnings)', aliases: ['fix-php'])]
function fix_php(): int
{
Expand Down Expand Up @@ -357,13 +370,14 @@ function lint_all(): int
{
title('lint:all');
$ec1 = stan();
$ec2 = lint_php();
$ec3 = lint_doctrine();
$ec4 = lint_js_css();
$ec5 = lint_container();
$ec6 = lint_twig();

return success($ec1 + $ec2 + $ec3 + $ec4 + $ec5 + $ec6);
$ec2 = psalm();
$ec3 = lint_php();
$ec4 = lint_doctrine();
$ec5 = lint_js_css();
$ec6 = lint_container();
$ec7 = lint_twig();

return success($ec1 + $ec2 + $ec3 + $ec4 + $ec5 + $ec6 + $ec7);

// if you want to speed up the process, you can run these commands in parallel
// parallel(
Expand Down
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
"symfony/requirements-checker": "^2.0",
"symfony/stopwatch": "~8.0.0",
"symfony/web-profiler-bundle": "~8.0.0",
"vimeo/psalm": "^6.14",
"zenstruck/foundry": "^2.4"
},
"replace": {
Expand Down
Loading