php-cs-fixer or custom sniffs).🔧 sniffs), reducing manual refactoring effort.slevomat/coding-standard) and configured in phpcs.xml without Laravel-specific modifications.--parallel flag) for large codebases.| Risk Area | Mitigation Strategy |
|---|---|
| Rule Overlap | Audit existing php-cs-fixer/PSR-12 rules to avoid conflicts; prioritize Slevomat for functional safety (e.g., DisallowNullSafeObjectOperator). |
| Performance Impact | Run in CI only initially; benchmark on large codebases (e.g., 50K+ LOC). |
| Developer Adoption | Start with non-breaking rules (e.g., formatting) before enforcing functional checks. |
| False Positives | Leverage phpcs --report=emacs for granular feedback; suppress rules via comments (// phpcs:ignore). |
| Maintenance Burden | Document allowed exceptions (e.g., legacy code) in CONTRIBUTING.md. |
php-cs-fixer configurations?php-cs-fixer?DisallowYodaComparison)?slevomat/coding-standard + squizlabs/php_codesniffer).app/, packages/) to reduce runtime.| Phase | Action | Tools/Artifacts |
|---|---|---|
| Assessment | Run Slevomat against sample modules to identify violations. | phpcs --standard=Slevomat --report=full |
| Pilot | Enforce non-breaking rules (formatting, doc comments) in a single module. | phpcs --ruleset=custom.ruleset.xml |
| Gradual Rollout | Expand to functional rules (e.g., DisallowNullSafeObjectOperator) per team. |
CI gates, Slack alerts for violations. |
| Full Enforcement | Integrate into pre-commit (Husky) and CI with blocking failures. | GitHub Actions, Laravel Forge hooks. |
phpcs natively.Arrays.AlphabeticallySortedByKeys may clash with php-cs-fixer’s array formatting.phpcs --ignore=SlevomatCodingStandard.Arrays.* for overlapping rules.make lint) to catch issues early.- name: Run Slevomat Coding Standard
run: vendor/bin/phpcs --standard=Slevomat --report=emacs --error-severity=1
Arrays.TrailingArrayComma).Classes.ForbiddenPublicProperty).composer update slevomat/coding-standard in CI to test new rules.DisallowNullSafeObjectOperator).ruleset.xml in the repo to override defaults (e.g., disable Classes.ClassLength).<rule ref="SlevomatCodingStandard">
<exclude name="SlevomatCodingStandard.Classes.ClassLength"/>
<config name="SlevomatCodingStandard.Arrays.AlphabeticallySortedByKeys" value="true"/>
</rule>
CODE_STANDARD.md with:
// phpcs:ignore).DisallowNullSafeObjectOperator).Arrays.AlphabeticallySortedByKeys).--parallel=8 to distribute checks across CPU cores.vendor/ and node_modules/ via .phpcs.exclude.phpcs --config=local.ruleset.xml) for WIP code.| Failure Mode | Impact | Mitigation |
|---|---|---|
| CI Blockage | Broken PRs due to strict rules. | Start with --warning-severity=1. |
| False Positives | Legitimate code flagged. | Use phpcs --report=emacs for details. |
| Toolchain Breakage | phpcs version incompatibility. |
Pin squizlabs/php_codesniffer:^3.6. |
| Developer Burnout | Overwhelming violations. | Gradual enforcement + autofix. |
How can I help you explore Laravel packages today?