Static analysis and code quality
The Yii application template includes static analysis and code quality tools alongside the test suite.
Psalm
Run Psalm locally:
vendor/bin/psalmRun Psalm in Docker:
make psalmThe template stores Psalm configuration in psalm.xml. The GitHub Actions workflow runs Psalm for supported PHP versions.
When Psalm reports an issue, fix the code or add a precise type annotation. Keep suppressions narrow and local to the line or method that needs them.
Composer Dependency Analyser
Composer Dependency Analyser checks that composer.json matches the classes used by the application.
Run it locally:
vendor/bin/composer-dependency-analyser --config=composer-dependency-analyser.phpRun it in Docker:
make composer-dependency-analyserUse this check after adding or removing package usage in src, config, or tests.
PHP CS Fixer
PHP CS Fixer applies the project coding style from .php-cs-fixer.php.
Run it locally:
vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.php --diffRun it in Docker:
make cs-fixCommit formatting changes together with the code that needs them.
Rector
Rector applies configured code upgrades and refactorings from rector.php.
Preview changes locally:
vendor/bin/rector --dry-runApply changes locally:
vendor/bin/rectorRun it in Docker:
make rectorReview Rector changes before committing them. Automated refactoring can change behavior when custom rules or broad paths are configured.
Pull request checks
A practical local check before opening a pull request is:
APP_ENV=test vendor/bin/codecept build
APP_ENV=test vendor/bin/codecept run
vendor/bin/psalm
vendor/bin/composer-dependency-analyser --config=composer-dependency-analyser.php
vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.php --diffWith Docker:
make codecept build
make test
make psalm
make composer-dependency-analyser
make cs-fix