Create Rector rule for converting procedural hook implementations to OOP
>>> [!note] Migrated issue <!-- Drupal.org comment --> <!-- Migrated from issue #3481215. --> Reported by: [nicxvan](https://www.drupal.org/user/531480) >>> <h2>Drupal version</h2> <p>Not in yet</p> <h2>MR on Github</h2> <p><a href="https://github.com/palantirnet/drupal-rector/pull/308">https://github.com/palantirnet/drupal-rector/pull/308</a></p> <h2>Drupal Rector version</h2> <p>Not in yet</p> <h2>Problem / Motivation</h2> <p>When <span class="drupalorg-gitlab-issue-link project-issue-status-info project-issue-status-7"><a href="https://www.drupal.org/project/drupal/issues/3442009" title="Status: Closed (fixed)">#3442009: OOP hooks using attributes and event dispatcher</a></span> lands it would be nice to have a rector rule to convert the procedural hooks into OOP attributes.</p> <p>I've moved the rule @ghostofdrupalpast wrote to the PR.</p> <p>I need some advice on how to include this more properly as for now for testing I've just replaced all rules with only this rule.</p> <p>This is probably fine for a one time or per module run for core. Once core deprecates procedural hooks we can move this to a normal deprecation.</p> <p>This does need some work from <span class="drupalorg-gitlab-issue-link project-issue-status-info project-issue-status-7"><a href="https://www.drupal.org/project/coder/issues/3461148" title="Status: Closed (fixed)">#3461148: Drupal.WhiteSpace.ScopeIndent gets confused by attributes on a function.</a></span> as well, if you look at the gist below you can see there are still some spacing issues: <a href="https://gitlab.com/-/snippets/3759543">https://gitlab.com/-/snippets/3759543</a></p> <p>Specifically look at the indentation of the function declarations after the attribute.<br> Also note that the attributes are fully expanded.</p>
issue