.PHONY: help test arch lint warmup cache-clear

# Default PHP command (can be overridden)
PHP ?= docker run --rm -v "$$(pwd):/app" -w /app php:8.5-cli php

help: ## Display this help
	@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}'

test: ## Run PHPUnit tests
	$(PHP) ./vendor/bin/phpunit --testdox

arch: ## Run architecture tests (PHPat via PHPStan)
	$(PHP) ./vendor/bin/phpstan analyse tests/Architecture --configuration=phpstan.neon --level=1

lint: ## Run PHPStan static analysis
	$(PHP) ./vendor/bin/phpstan analyse --configuration=phpstan.neon

warmup: ## Warmup Symfony cache (avoids timeout in web requests)
	$(PHP) ./bin/console cache:warmup --env=dev
	$(PHP) ./bin/console cache:warmup --env=prod

cache-clear: ## Clear Symfony cache
	$(PHP) ./bin/console cache:clear --env=dev
	$(PHP) ./bin/console cache:clear --env=prod

cs-fix: ## Run PHP-CS-Fixer
	$(PHP) ./vendor/bin/php-cs-fixer fix

ci: lint arch test ## Run all CI checks (lint, arch, test)
