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.
Hooks are documented in *.api.php files. Developers tend to copy hooks from those files or from api.drupal.org which is bullt upon the code documentation. On the other hand drush generate
and PhpStorm use these definitions as templates for generating hooks. Unfortunately, the hook definitions largely does not use typehints. As a result developers have to update the generated code manually or just do not use typehints at all.
Add proper typehints to hooks in all *.api.php files.
The changes would look like this.
- function hook_contextual_links_view_alter(&$element, $items) {
+ function hook_contextual_links_view_alter(array &$element, array $items): void {
Discuss, create a mega patch, review and commit it.
None.
Active
11.0 🔥
Enhances developer experience.
Not all content is available!
It's likely this issue predates Contrib.social: some issue and comment data are missing.
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.