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.
calmfox/watch-sylius
damienfern/grpc-symfony-bundle
atoolo/index-bundle
atoolo/genai-bundle
coprotoai/laravel-ticket
davidjln/llm-carbon-bundle
cryonighter/valid-request-bundle
coolms/taxonomy-bundle
coolms/field-bundle
articulate-orm/symfony
aaix/laravel-tall-architect
ephoto/akeneo-connector
emmanuelballery/eb-plantumlbundle
emielburgman/symfony-visitor-beacon
emielburgman/symfony-visit-storage
emielburgman/symfony-security-headers
emielburgman/symfony-log-viewer
emarref/xdebug-bundle
emarref/pubnub-bundle
elriseio/finance-money-bundle