ninjify/coding-standard
PHP_CodeSniffer coding standard for PHP projects. Install via Composer and include the provided ruleset.xml or Contributte profile. Supports excluding paths and ships PhpStorm code style presets. Maintained by Contributte.
Strengths:
tests/tmp) and pre-configured rulesets (e.g., Contributte, Gamee).Potential Conflicts:
php-cs-fixer (PSR-12) may conflict with this package’s stricter rules (e.g., disallowed ternary operators, strict type declarations). Requires explicit alignment.php-cs-fixer or phpmd workflows.pre-push scripts.php-cs-fixer if stricter standards are desired.php-cs-fixer configs or custom sniffs. Mitigation: Audit current rulesets and merge selectively.exclude-pattern to isolate high-maintenance areas (e.g., vendor files, generated code).slevomat/coding-standard (v7+), which may introduce breaking changes. Last update was 2022-02-11—monitor for forks or successors.^0.12) and test upgrades annually.php-cs-fixer rules that conflict with this package’s defaults?composer require --dev ninjify/coding-standard.php ./vendor/bin/phpcs --standard=ruleset.xml).phpstorm/ folder in the package).php-cs-fixer (if stricter rules are desired).php-cs-fixer for layered validation (e.g., php-cs-fixer for PSR-12, this package for additional checks).phpmd or custom scripts for broader static analysis.composer require --dev ninjify/coding-standard
php ./vendor/bin/phpcs --standard=./vendor/ninjify/coding-standard/ruleset.xml --report=full src/
exclude-pattern to isolate changes.ruleset.xml:
<ruleset name="Acme">
<rule ref="./vendor/ninjify/coding-standard/ruleset.xml"/>
<exclude-pattern>./vendor</exclude-pattern>
<exclude-pattern>./tests/Feature/SlowTests.php</exclude-pattern>
</ruleset>
FIXME comment template for developers to document intentional violations..idea/codestyle/ or team-wide settings..blade.php) unless custom sniffs are added.public function __get(string $name)) as non-compliant. Document exceptions.register()/boot() methods may require adjustments (e.g., no ternary operators in dependency resolution).friendsofphp/php-cs-fixer by either:
php-cs-fixer config.phpcs hooks (e.g., with roave/security-advisories or custom scripts).composer.json dev requirements and document in CONTRIBUTING.md.CODE_STYLE.md in the repo explaining exceptions (e.g., "We allow ternary operators in Blade templates").ruleset.xml configs for common Laravel use cases.exclude-pattern to avoid scanning generated code (e.g., migrations, model casts).<exclude-pattern>./database/migrations/*</exclude-pattern>
<exclude-pattern>./app/Models/Casts/*</exclude-pattern>
| Failure Mode | Impact | Mitigation |
|---|---|---|
| CI Blockages | Slows down PRs if rules are too strict. | Start with warnings, then enforce gradually. |
| Rule Conflicts | Breaks existing code. | Audit rulesets pre-integration; use exclusions. |
| Outdated Package | No updates for PHP 8.2+. | Monitor for forks or migrate to alternatives. |
| Developer Pushback | Team resists strict rules |
How can I help you explore Laravel packages today?