Product Decisions This Supports
- Standardizing codebase formatting to reduce cognitive load for developers and improve maintainability.
- Enforcing consistency in PHP/Laravel projects by adopting a unified coding style (e.g., "One True Brace," newline rules, closure spacing).
- Automating code reviews by integrating with CI/CD pipelines to catch formatting violations early (e.g., trailing newlines, binary operation alignment).
- Scaling developer onboarding by reducing subjective style debates and providing clear, actionable feedback via
phpcs.
- Roadmap alignment: Prioritize this for teams adopting Laravel/PHP 8.x+ or migrating legacy codebases to modern standards.
- Build vs. buy: Justify adopting this over custom rules or PSR-12 alone by offering Corpus-specific sniffs (e.g.,
MethodParameterFormattingSniff with configurable line length) and Slevomat/Squiz best practices in one package.
When to Consider This Package
-
Adopt if:
- Your team uses PHP_CodeSniffer (or plans to) and wants Corpus/Slevomat/Squiz standards pre-configured.
- You need customizable formatting rules (e.g., max parameter line length, brace styles) beyond PSR-12.
- Your codebase has mixed formatting styles (e.g., K&R vs. Allman braces) and requires enforcement.
- You’re onboarding new developers or merging contributions from external teams.
- Your CI/CD pipeline lacks automated linting for PHP style violations.
-
Look elsewhere if:
- You’re locked into PSR-12 and don’t need Corpus/Slevomat extensions.
- Your team prefers manual code reviews over automated tooling.
- You use PHPStan/Psalm exclusively and prioritize static analysis over formatting.
- Your project is small or monorepo with negligible style drift risk.
- You lack PHP_CodeSniffer infrastructure (e.g., no Composer dev dependencies).
How to Pitch It (Stakeholders)
For Executives:
"This package standardizes our PHP/Laravel codebase to a maintainable, scalable format—reducing merge conflicts, onboarding time, and manual review overhead. By automating style enforcement (e.g., brace placement, line breaks) via CI, we’ll catch issues early and align with industry best practices (Slevomat, Squiz). It’s a low-effort, high-impact fix for technical debt, with minimal runtime cost."
Key Outcomes:
- Faster PR merges (fewer style-related comments).
- Consistent codebase for new hires.
- Proactive quality gates in CI.
For Engineering Teams:
*"This PHP_CodeSniffer extension combines Corpus-specific rules (e.g., parameter formatting, closure spacing) with Slevomat/Squiz standards to enforce a unified style. It’s lightweight, configurable, and integrates seamlessly with Laravel projects. Use it to:
- Auto-fix common formatting issues (e.g., trailing newlines, binary operators).
- Enforce ‘One True Brace’ or custom line-length rules for parameters.
- Reduce noise in code reviews by automating style checks.
Setup:
composer require --dev corpus/coding-standard
phpcs --standard=Corpus path/to/codebase
Why now? It’s battle-tested (PHP 8.4+), MIT-licensed, and extends PSR-12 without reinventing the wheel."*
Trade-offs:
- Pros: Opinionated but flexible (e.g., tweak
maxLength for parameters).
- Cons: Requires
phpcs in CI; minimal performance overhead.