Skip to content

Skip 'RemoveUnusedPublicMethodParameterRector' for hook implementations #2982

Description

@AlexSkrypnyk

Summary

Drupal 11 object-oriented hook implementations must keep the framework-required method signature whether or not every parameter is used. RemoveUnusedPublicMethodParameterRector sees the unused parameter and removes it, which breaks the hook.

Two downstream Vortex sites on different teams hit this independently.

Details

Add a scoped skip rather than a blanket one, so the rule stays active everywhere the signature is genuinely the author's to choose:

RemoveUnusedPublicMethodParameterRector::class => [
  // Object-oriented hook implementations must keep the framework-required
  // signature even when a parameter is unused.
  __DIR__ . '/web/modules/custom/*/src/Hook/*',
],

One downstream site scoped it to the Hook directory as above; another disabled the rule globally. The scoped form is the one to adopt.

Worth settling in the same pass:

  • Whether the same reasoning applies to other framework-fixed signatures, such as event subscriber methods and plugin create() factories.
  • Whether the path pattern should cover custom themes as well as custom modules.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A2Working clone index A2

    Type

    No type

    Projects

    • Status
      Released in 1.41.0

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions