Static analysis and code quality
The Yii application template includes static analysis and code quality tools alongside the test suite.
Psalm
Run Psalm locally:
shell
vendor/bin/psalmRun Psalm in Docker:
shell
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:
shell
vendor/bin/composer-dependency-analyser --config=composer-dependency-analyser.phpRun it in Docker:
shell
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:
shell
vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.php --diffRun it in Docker:
shell
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:
shell
vendor/bin/rector --dry-runApply changes locally:
shell
vendor/bin/rectorRun it in Docker:
shell
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:
shell
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:
shell
make codecept build
make test
make psalm
make composer-dependency-analyser
make cs-fix