OOP hook legacy support change record

Description: 

  1. Create a class in the Drupal\modulename\Hook namespace (or subdirectory). This will be automatically registered as an autowired service.
  2. Use the new Drupal\Core\Hook\Attribute\Hook attribute either on methods or on the class. If it is on the class and the class doesn't have an __invoke method then a method argument is required.

https://www.drupal.org/node/3442349

node.module

use Drupal\Core\Hook\Attribute\LegacyHook;
use Drupal\node\Hook\NodeHooks;

// @phpstan-ignore-next-line
#[LegacyHook]
function node_user_cancel($edit, UserInterface $account, $method) {
  // This only needs to be returned if the hook previously had a return.
  return \Drupal::service(NodeHooks::class)->userCancel($edit, $account, $method);
}