Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Php Cs Fixer Custom Fixers Laravel Package

kubawerlos/php-cs-fixer-custom-fixers

Adds a curated set of custom fixers for PHP-CS-Fixer to enforce consistent, opinionated code style beyond the built-in rules. Plug in the fixers, combine with your config, and keep large PHP codebases clean and uniform.

View on GitHub
Deep Wiki
Context7

Getting Started

  1. Install via Composer: composer require --dev kubawerlos/php-cs-fixer-custom-fixers.
  2. Require PHP-CS-Fixer as a peer dependency (this package extends it): composer require --dev friendsofphp/php-cs-fixer.
  3. Enable fixers in your existing .php-cs-fixer.php config file (e.g., below standard config setup):
    $finder = PhpCsFixer\Finder::create()
        ->in(__DIR__)
    ;
    
    return (new PhpCsFixer\Config())
        ->setRules([
            // Enable custom fixers by name
            'kubawerlos/no_superfluous_elseif' => true,
            'kubawerlos/strict_param_call' => true,
            // ...other rules...
        ])
        ->setFinder($finder);
    
  4. Run ./vendor/bin/php-cs-fixer fix --dry-run to preview changes before applying.
    First use case: Enforce strict type usage in function calls (kubawerlos/strict_param_call) to avoid runtime type coercion bugs.

Implementation Patterns

  • Selective adoption: Start with 1–2 safe, high-impact fixers (e.g., no_superfluous_elseif, single_line_after_imports) and gradually expand.
  • Config organization: Group custom fixers in rules config for readability:
    'rules' => [
        '@PSR12' => true,
        'kubawerlos/no_superfluous_elseif' => true,
        'kubawerlos/strict_comparison' => true,
        'kubawerlos/no_useless_else' => true,
    ]
    
  • CI integration: Run checks with --diff --dry-run in CI (GitHub Actions, GitLab CI) to fail builds on style violations—no changes needed in Docker container unless fixing.
  • Extending: Override behavior of built-in PHP-CS-Fixer rules only where custom fixers provide clear utility (e.g., kubawerlos/concat_space enforces str . $var vs str.$var).
  • Team rollout: Share the full list of available fixers and get buy-in via code review—don’t auto-apply all at once.

Gotchas and Tips

  • Fixer naming: All fixers are prefixed with kubawerlos/. Forgetting the prefix (e.g., no_superfluous_elseifkubawerlos/no_superfluous_elseif) causes silently ignored rules—check logs with --verbose.
  • PHP version compatibility: Ensure your project’s PHP version matches the fixer requirements (e.g., some enforce typed properties or union types—requires PHP ≥8.0).
  • Order matters: Some fixers interact with others (e.g., kubawerlos/strict_comparison may conflict with @Symfony rules around == vs ===). Use php-cs-fixer fix --diff --dry-run to inspect side effects.
  • Debugging: Add 'verbose' => true in config or run with --debug to trace fixer execution—especially helpful when a rule should fire but doesn’t.
  • Extensibility point: You can contribute new fixers or fork locally for proprietary rules—package is designed for this.
  • Version pinning: Lock to a minor version (e.g., ^3.0) since new fixers may break builds unexpectedly—review changelog before upgrades.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
davejamesmiller/laravel-breadcrumbs
artisanry/parsedown
christhompsontldr/phpsdk
enqueue/dsn
bunny/bunny
enqueue/test
enqueue/null
enqueue/amqp-tools
milesj/emojibase
bower-asset/punycode
bower-asset/inputmask
bower-asset/jquery
bower-asset/yii2-pjax
laravel/nova
spatie/laravel-mailcoach
spatie/laravel-superseeder
laravel/liferaft
nst/json-test-suite
danielmiessler/sec-lists
jackalope/jackalope-transport