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 Custom Fixer Laravel Package

pedrotroller/php-cs-custom-fixer

Custom fixers for PHP-CS-Fixer. Adds rules like ordering Behat context step definition methods by annotation and method name, with options for detecting context classes. Install via Composer and register the fixers in your .php_cs(.dist) config.

View on GitHub
Deep Wiki
Context7

Getting Started

  1. Install the package: Run composer require pedrotroller/php-cs-custom-fixer --dev.
  2. Configure PHP-CS-Fixer: In your .php_cs.dist (or .php_cs), register the custom fixers using ->registerCustomFixers(new PedroTroller\CS\Fixer\Fixers()).
  3. Enable a fixer: Add 'PedroTroller/ordered_with_getter_and_setter_first' => true (or another fixer) in setRules().
  4. Run it: Execute ./vendor/bin/php-cs-fixer fix to auto-fix your codebase.
    ➡️ First use case: Enforce consistent method ordering in value objects and DTOs to improve readability and maintainability—especially in large codebases with many developers.

Implementation Patterns

  • RuleSetFactory integration: Use PedroTroller\CS\Fixer\RuleSetFactory::create()->enable('...')->getRules() for cleaner, self-documenting rule configuration.
  • Config-driven behavior: Many fixers (e.g., PedroTroller/order_behat_steps) accept configuration arrays (e.g., 'instanceof' => [...]) to tailor detection to your project’s context hierarchy.
  • CI integration: Use in pre-commit hooks (via php-cs-fixer fix --diff --dry-run) or CI pipelines to block non-compliant code.
  • Selective enabling: Enable only fixers relevant to your stack (e.g., only PedroTroller/order_behat_steps in Behat-heavy projects).
  • Extensibility: Combine with other custom fixers or standard PHP-CS-Fixer rules without conflicts.

Gotchas and Tips

  • Case sensitivity: Fixer names are case-sensitive—use PedroTroller/..., not pedrotroller/... (Laravel’s config caching won’t help here).
  • Order matters: PHP-CS-Fixer applies rules sequentially; use 'PedroTroller/ordered_with_getter_and_setter_first' => ['after' => ['foo', 'bar']] if other rules interfere (though not documented, inspect diff carefully).
  • Behat context detection: If your contexts extend non-standard interfaces or abstract classes, override instanceof explicitly (e.g., 'instanceof' => ['App\Behat\Context\CustomContext']).
  • No PSR-12 compatibility guarantee: Some fixers reorder accessors before other structural elements—ensure alignment with your team’s agreed class structure (e.g., properties → constructor → methods).
  • Debug tip: Run vendor/bin/php-cs-fixer fix --rules='PedroTroller/order_behat_steps' --dry-run -vvv to see diffs + debug config loading.
  • Maturity note: With only 81 stars and no Composer dependents, test upgrades carefully—review PRs in the repo before updating.
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.
hexters/coinpayment
rjcodes/rjcms
act-training/laravel-permissions-manager
alimarchal/laravel-chart-of-accounts
babenkoivan/elastic-scout-driver
mkwebdesign/filament-watchdog-v5
renatomarinho/laravel-page-speed
zedmagdy/filament-business-hours
renatovdemoura/blade-elements-ui
devgeek/beacon-admin
benjamin-rqt/data-watcher-bundle
atriumphp/atrium
sandermuller/package-boost-laravel
sandermuller/boost-skills
redaxo/core
yusufgenc/filament-api-forge
l3aro/rating-star-for-filament
leek/filament-subtenant-scope
anil/file-picker
broqit/fields-ai