I think it's a good idea. I've been using type hints in my hook implementations, even if the hook itself doesn't specify types. I'm trying to use stricter coding standards.
- Status changed to Closed: duplicate
3 months ago 1:41pm 22 January 2025 - 🇦🇺Australia mstrelan
Re-opening and moving to a child of 📌 [META] Add return types to hook implementations Active because there are a lot of hook definitions (in .api.php files) that were not updated in some of the wildcard issues, like all info hooks. I think we can use this to identify and fix any leftovers.
- 🇦🇺Australia mstrelan
Postponing on 📌 Add void return to @ingroup entity_crud hook implementations Active and 📌 Add return type to remaining hook implementations Active . Added steps to reproduce. Added a draft MR with all the alter hooks updated.
- 🇦🇺Australia mstrelan
No longer postponed. Just realised that the IS is talking about both params and return types. I think initially we should limit this to return types and split off params to another ticket.
- 🇦🇺Australia mstrelan
$ grep -rn --include="*.api.php" -E 'function hook_.*\(.*\) \{' core core/lib/Drupal/Core/Extension/module.api.php:782:function hook_update_N(&$sandbox) { core/lib/Drupal/Core/Extension/module.api.php:784: // function hook_update_N() { core/lib/Drupal/Core/Extension/module.api.php:892:function hook_post_update_NAME(&$sandbox) { core/lib/Drupal/Core/Extension/module.api.php:1303:function hook_update_requirements() { core/modules/shortcut/shortcut.api.php:40:function hook_shortcut_default_set(AccountInterface $account) { core/modules/jsonapi/jsonapi.api.php:276:function hook_jsonapi_entity_filter_access(EntityTypeInterface $entity_type, AccountInterface $account) { core/modules/field/field.api.php:394:function hook_field_info_max_weight($entity_type, $bundle, $context, $context_mode) {
- First commit to issue fork.
- First commit to issue fork.
The Needs Review Queue Bot → tested this issue. It no longer applies to Drupal core. Therefore, this issue status is now "Needs work".
This does not mean that the patch necessarily needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.
Consult the Drupal Contributor Guide → to find step-by-step guides for working with issues.
The Needs Review Queue Bot → tested this issue. It no longer applies to Drupal core. Therefore, this issue status is now "Needs work".
This does not mean that the patch necessarily needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.
Consult the Drupal Contributor Guide → to find step-by-step guides for working with issues.