- How do I install this package for Laravel projects?
- Run `composer require --dev kubawerlos/php-cs-fixer-custom-fixers` in your Laravel project. The package is designed as a dev dependency, so it won’t affect production builds. Ensure your project uses PHP 7.4+ for full compatibility.
- Can I use these fixers alongside Laravel’s default PHP CS Fixer config?
- Yes, the package integrates directly with your existing `.php-cs-fixer.php` config. Call `registerCustomFixers()` and enable specific rules (e.g., `ClassConstantUsageFixer`) alongside PSR-12 or PSR-2 rules. Test with `--dry-run` first to avoid unexpected changes.
- Which Laravel versions are supported?
- This package works with Laravel 8+ and PHP 7.4+. Some fixers (e.g., `NoNullableBooleanTypeFixer`) may conflict with older Laravel versions (pre-5.5) due to PHP 7.4+ assumptions. Always validate with `--dry-run` before enforcing in CI.
- How do I handle conflicts with existing codebases?
- Start by running fixers in `--dry-run` mode to identify conflicts. Use the `Risky` flag in the docs to avoid problematic fixers (e.g., `IssetToArrayKeyExistsFixer`). For legacy code, consider opting out specific files or classes via config annotations.
- Are these fixers safe for Laravel’s test suite?
- Most fixers are safe, but some (e.g., `PhpUnitAssertArgumentsOrderFixer`) may break PestPHP or PhpUnit assertions. Test against your Laravel test suite before enforcing globally. Use `--diff` to preview changes and validate manually.
- How do I integrate this into GitHub Actions for Laravel?
- Add a step to your workflow using `vendor/bin/php-cs-fixer fix --diff --dry-run --rules=@PSR12,NoLeadingSlashInGlobalNamespaceFixer`. For pre-commit hooks, use `php-cs-fixer fix --allow-risky=yes` if needed, but avoid risky fixers in CI.
- What’s the performance impact on large Laravel codebases?
- Running all fixers on large codebases (e.g., Laravel’s test suite) can introduce CI overhead. Profile with `--dry-run` and `--stop-on-failure` to measure impact. Disable deprecated or risky fixers if performance is critical.
- Are there alternatives for stricter Laravel code standards?
- Native PHP CS Fixer rules (e.g., `@PSR12`) cover most standards, but this package adds opinionated fixes like `ClassConstantUsageFixer` or `NoUselessCommentFixer`. For Laravel-specific rules, consider `laravel-shift/php-cs-fixer-laravel` or custom configs.
- How do I handle deprecated fixers in this package?
- Deprecated fixers (e.g., `DataProviderNameFixer`) are marked in the docs. Plan to migrate to native PHP CS Fixer rules (e.g., `php_unit_data_provider_name`) when Laravel adopts them. Use `--dry-run` to test replacements incrementally.
- Will these fixers break Laravel’s Doctrine ORM interactions?
- Some fixers (e.g., `NoLeadingSlashInGlobalNamespaceFixer`) are safe, but others (e.g., `IssetToArrayKeyExistsFixer`) may conflict with Doctrine’s dynamic property access. Test with `--dry-run` and exclude problematic files if needed.