As per the core change record:
Support for object oriented hook implementations using autowired services β
As of core Drupal 11.1, hooks can be written as instance methods on a class rather than procedural methods in a module file. This change is backwards compatible with Drupal 10 as well.
Active
2.0
Code