PHP Festi Coding Standard
The shared quality toolchain for Festi PHP projects, installed as one
Composer dev dependency: festi-team/coding-standard.
| What you get | Tool | Looks at |
|---|---|---|
The Festi coding standard |
PHP_CodeSniffer | style, naming, docblocks, complexity of one function |
| Class-design limits | PHPMD | size and coupling of a class, parameter counts |
| A Phan baseline and Festi plugins | Phan | types, plane separation, SQL injection, disabled guards |
festi-quality |
all of the above, plus SonarQube's open issues | one summary for a project, some paths, or a change |
festi-phpcs-diff |
PHP_CodeSniffer | the merge request gate: only the lines a branch changed |
| Reusable GitLab CI jobs | the same checks in a pipeline |
The same rules run in every project's pipeline and in the
agent_festireview review bot, so there is one source of truth.
Quick start
composer require --dev festi-team/coding-standard
Allow the Composer plugin that registers the standard with phpcs, in the
project's composer.json:
"config": {
"allow-plugins": {
"dealerdirect/phpcodesniffer-composer-installer": true
}
}
Then, from the project root:
vendor/bin/festi-quality # the whole project
vendor/bin/festi-quality src tests/Unit # these files and directories
vendor/bin/festi-quality --diff # only what this branch changed
vendor/bin/festi-quality --diff --list # ... with every issue and its line
vendor/bin/festi-quality --diff --strict # ... and fail when there is one
Festi quality summary
Scope: lines changed since origin/develop, in 3 file(s)
phpcs 2 issues 2 errors, 0 warnings, 1 auto-fixable
phpmd 0 issues
phan 0 issues
sonar SKIPPED set SONAR_HOST_URL and SONAR_TOKEN to read com.festi:cli
phpcs by rule
1 Generic.Arrays.DisallowLongArraySyntax.Found
1 Festi.NamingConventions.EntityIdNaming.VariableIdNaming
A Festi project is expected to have all three set up: the coding standard, a Phan configuration and a SonarQube project. Installation covers each.
Documentation
| Read | To |
|---|---|
| Installation | install the package, set up Phan and SonarQube, migrate an existing project |
| Usage | run the checks: the whole project, paths, or a change; options, exit codes, the tools one by one |
| GitLab CI | add the shipped jobs to a pipeline |
| Rules | see what each rule asks for, with examples |
| Configuration | change a limit, switch a rule off, tune a Phan plugin, adopt a rule on a codebase with a backlog |
| Extending | add a sniff, a PHPMD rule, a Phan plugin or a tool to festi-quality; test and release it |
Requirements
| Constraint | |
|---|---|
| PHP | >=8.1 |
squizlabs/php_codesniffer |
^3.7.1 \|\| ^4.0 |
phan/phan |
^6.0 |
phpmd/phpmd |
^2.15 |
slevomat/coding-standard |
^8.22 |
All of them come with the package; a project does not require them itself.