PHP-CS-Fixer
$ php-cs-fixer Community Low RiskStandard PHP coding-standards fixer enforcing PSR-12, Symfony, and PER Coding Style rules across PHP repositories. Supports non-destructive --dry-run --diff previews and structured --format=json output.
brew install php-cs-fixer Formats local PHP repositories directly; CLI execution is simple and offline.
Agent-Readiness Checklist
Static evaluation (not yet probed on this host). Run npm run data:probe locally to capture live verification.
FCRS-1.0 6-Dimension Breakdown
Supports --dry-run, --diff, --format=json, --stop-on-violation, and clear exit codes.
--dry-run --diff --format=jsongives structured JSON diff reports
Blocks risky rules unless --allow-risky=yes is passed, though fix mutates files unless --dry-run is specified.
- Separates risky fixers behind
--allow-risky=yes - Requires
--dry-runbecausefixis the primary subcommand
Requires a PHP runtime (brew install php-cs-fixer or Composer friendsofphp/php-cs-fixer).
- Depends on compatible host PHP version
Canonical PHP style fixer with parallel runner and .php-cs-fixer.cache speedup.
- Supports PSR-12, PER-CS, and Symfony presets
Widely adopted community/Symfony-ecosystem project (PHP-CS-Fixer/PHP-CS-Fixer) under MIT license.
- Maintained at
PHP-CS-Fixer/PHP-CS-Fixer
Well-maintained documentation for CLI options, rules, and config at cs.symfony.com.
- Official docs at cs.symfony.com/doc/usage.html
Security, Auth & Guardrails
Offline local PHP formatter; no credentials stored or required.
MIT open-source PHP tool; completely free.
# PHP-CS-Fixer Agent Rules - Always pass `--dry-run --diff --format=json` before running `php-cs-fixer fix` without `--dry-run`. - Respect the repo's `.php-cs-fixer.dist.php` config and avoid `--allow-risky=yes` unless explicitly requested.
Agent-Ready Command Recipes
Safe Read-Only Queries
php-cs-fixer fix --dry-run --diff --format=json src/
Reports files needing fixes plus diffs in JSON and exits non-zero without editing files.
Controlled Writes & Previews
php-cs-fixer fix --format=json src/Controller/
Applies configured PSR-12/Symfony fixes in place to src/Controller/.
Strengths for Agents
- +
--dry-run --diff --format=jsoncombines safe read-only preview with structured JSON diffs. - + Explicitly gates semantic-changing rules behind
--allow-risky=yes.
Caveats & Pitfalls
- ! Primary subcommand is
fix, so forgetting--dry-runimmediately modifies files. - ! Requires matching PHP runtime version (may fail on newer PHP syntax until updated).