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

Styleci Fixers Laravel Package

sllh/styleci-fixers

View on GitHub
Deep Wiki
Context7

Getting Started

Minimal Setup

  1. Installation

    composer require --dev sllh/styleci-fixers
    

    Note: This package is a dependency for sllh/php-cs-fixer-styleci-bridge. Use that package instead for direct integration.

  2. First Use Case

    • If using php-cs-fixer-styleci-bridge, configure it to load StyleCI rules via this package’s generated fixers.
    • Example bridge config (in php-cs-fixer.dist.php):
      use Sllh\StyleCiFixer\StyleCiFixer;
      
      $finder = PhpCsFixer\Finder::create()->in(__DIR__.'/../src');
      $styleCiFixer = new StyleCiFixer();
      return (new PhpCsFixer\Config())
          ->setRules($styleCiFixer->getRules())
          ->setFinder($finder);
      

Implementation Patterns

Workflow Integration

  1. Bridge-Based Workflow

    • Use php-cs-fixer-styleci-bridge as the primary tool, leveraging this package’s fixers under the hood.
    • Example CI workflow (GitHub Actions):
      - name: Run PHP-CS-Fixer
        run: vendor/bin/php-cs-fixer fix --config=php-cs-fixer.dist.php
      
  2. Dynamic Rule Loading

    • Fetch StyleCI rules dynamically (e.g., from a .styleci.yml file) and apply them via the bridge:
      $styleCiFixer = new StyleCiFixer();
      $rules = $styleCiFixer->loadFromStyleCiConfig(__DIR__.'/../.styleci.yml');
      
  3. Tag-Based Filtering

    • Apply fixers selectively using StyleCI tags (e.g., @risky):
      $styleCiFixer->setTags(['risky', 'modern']);
      

Laravel-Specific Tips

  • Artisan Command Integration Create a custom command to run StyleCI-compatible fixes:
    // app/Console/Commands/FixStyleCi.php
    namespace App\Console\Commands;
    
    use Illuminate\Console\Command;
    use Sllh\StyleCiFixer\StyleCiFixer;
    
    class FixStyleCi extends Command
    {
        protected $signature = 'styleci:fix';
        protected $description = 'Fix files using StyleCI rules';
    
        public function handle()
        {
            $finder = PhpCsFixer\Finder::create()->in(base_path('app'));
            $styleCiFixer = new StyleCiFixer();
            $config = (new PhpCsFixer\Config())
                ->setRules($styleCiFixer->getRules())
                ->setFinder($finder);
    
            (new PhpCsFixer\Cli\Application())
                ->run(new \Symfony\Component\Console\Input\ArrayInput([]), $config);
        }
    }
    
    Register it in app/Console/Kernel.php:
    protected $commands = [
        Commands\FixStyleCi::class,
    ];
    

Gotchas and Tips

Pitfalls

  1. Deprecated Package

    • This package is unmaintained. Use php-cs-fixer-styleci-bridge directly for production.
    • Rules may diverge from StyleCI’s latest SDK updates.
  2. Rule Conflicts

    • StyleCI’s aggressive rules (e.g., @risky fixers) may break functionality. Test thoroughly:
      vendor/bin/php-cs-fixer fix --dry-run --config=php-cs-fixer.dist.php
      
  3. Configuration Overrides

    • The bridge prioritizes .php-cs-fixer.dist.php over .styleci.yml. Explicitly merge rules if needed:
      $rules = array_merge(
          $styleCiFixer->getRules(),
          ['array_syntax' => ['syntax' => 'short']] // Override
      );
      

Debugging

  • Rule Inspection Dump loaded rules to debug:
    print_r($styleCiFixer->getRules());
    
  • Tag Validation Ensure tags in .styleci.yml match the bridge’s supported tags (check StyleCI SDK).

Extension Points

  1. Custom Rule Merging Extend the bridge to merge additional rules:

    $styleCiFixer->setRules(array_merge(
        $styleCiFixer->getRules(),
        ['no_unused_imports' => true]
    ));
    
  2. CI-Specific Configs Use environment variables to toggle rules in CI:

    $rules = $styleCiFixer->getRules();
    if (app()->environment('ci')) {
        $rules['phpdoc_align'] = false; // Disable in CI
    }
    
  3. Parallel Processing For large codebases, use PHP-CS-Fixer’s parallel mode:

    vendor/bin/php-cs-fixer fix --parallel
    
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.
daikazu/eloquent-salesforce-objects
unseen-codes/chat
romalytar/yammi-jobs-monitoring-laravel
kisame76/filament-db-table-state
nqxcode/laravel-lucene-search
dpfx/laravel-livewire-wizards
workos/workos-php-laravel
sofa/laravel-global-scope
nawasara/auth-primitives
adhocrat-io/arkhe-main
make-dev/orca-harpoon
itsemon245/lamet
baks-dev/dashboard
amoifr/pickle-panther-bundle
make-dev/orca
dmstr/symfony-system-resources-bundle
dmstr/symfony-job-queue-bundle
dmstr/openapi-json-schema-bundle
dmstr/keycloak-security-bundle
dmstr/doctrine-audit-log-bundle