Problem/Motivation

See #3483037: [META] Add return types to hook implementations

All info hooks should return array, except hook_config_translation_info which takes the $info param as a reference.

Steps to reproduce

Proposed resolution

Add array return to the following hook implementations:

  • hook_entity_bundle_info
  • hook_entity_base_field_info
  • hook_entity_bundle_field_info
  • hook_entity_field_storage_info
  • hook_entity_extra_field_info
  • hook_hook_info
  • hook_updater_info
  • hook_filetransfer_info
  • hook_token_info
  • hook_language_types_info

Remaining tasks

User interface changes

Introduced terminology

API changes

Data model changes

Release notes snippet

Issue fork drupal-3488841

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

mstrelan created an issue. See original summary.

mstrelan’s picture

Status: Active » Needs review
nicxvan’s picture

Status: Needs review » Reviewed & tested by the community

Looks good! Baseline looks right too.

quietone’s picture

Status: Reviewed & tested by the community » Needs work

I left some questions in the MR. Also, why are these not changed?

$ grep -r 'function.*hook_info(' core | grep -v array
core/tests/Drupal/Tests/Core/Extension/modules/module_handler_test/module_handler_test.module:function module_handler_test_hook_info() {
core/tests/Drupal/Tests/Core/GroupIncludesTestTrait.php:function test_module_hook_info() {
core/lib/Drupal/Core/Hook/HookCollectorPass.php:   * A list of functions implementing hook_hook_info().
core/modules/views/views.module:function views_hook_info() {
core/modules/system/tests/modules/module_test/module_test.module:function module_test_hook_info() {
core/modules/system/system.module:function system_hook_info() {
lavanyatalwar’s picture

Assigned: Unassigned » lavanyatalwar
mstrelan’s picture

Assigned: lavanyatalwar » Unassigned

Responded to some of the MR feedback, need further advice. Will look at the entity.api.php feedback too, it wasn't loading in the MR though.

Re #5:

  • The *_hook_infohooks were missed because my script was looking for a #[Hook] attribute in Hook classes. Could possibly be skipped due to #2233261: Deprecate hook_hook_info groups, mark hook_hook_info() for deletion
  • test_module_hook_info is actually in a heredoc string for writing a .module in a test, but I guess it could be included too
  • HookCollectorPass is just a comment talking about info hooks
mstrelan’s picture

Status: Needs work » Needs review

Addressed most feedback, 2 outstanding items in the MR for re-review.

mstrelan’s picture

Status: Needs review » Needs work

Needs rebase

Anonymous’s picture

akulsaxena made their first commit to this issue’s fork.

Anonymous’s picture

Hi @mstrelan

I resolved the Merge conflict in Baseline and Rebased the branch to the latest.
But the PHPSTAN pipeline shows some error in Baseline.
Can you please look into it

mstrelan’s picture

Best not to manually resolve conflicts in the baseline, just regenerate it.

Anonymous’s picture

mstrelan’s picture

Status: Needs work » Needs review

Rebased with these steps:

  • git rebase -i 11.x
  • Drop the baseline commit
  • Regenerate baseline with ./vendor/bin/phpstan --configuration=core/phpstan.neon.dist --generate-baseline=core/.phpstan-baseline.php
  • git add core/.phpstan-baseline.php
  • Commit and force push
nicxvan’s picture

Those steps good but you mean --force-with-lease right?

Anonymous’s picture

Rebased

Anonymous’s picture

Pipeline passed with all no errors/warnings

smustgrave’s picture

@akulsaxena unless the issue doesn't apply or the review bot kicks back a rebase is not needed.

Appears to be 2 open threads so leaving in review. As far as the workspace thread, even though we know workspaces is being updated think we have to make sure nothing bad is introduced here as we don't fully know when those overhaul tickets will land.

smustgrave’s picture

Status: Needs review » Needs work

Okay this has sat for a bit.

The first thread appears to have an open discussion.

For the workspace one should we postpone till workspace is refactored?

mstrelan’s picture

Status: Needs work » Needs review

Rebased the MR.

The first thread appears to have an open discussion.

I have refactored this as requested.

For the workspace one should we postpone till workspace is refactored?

Don't think so, there is no harm in leaving it in.

smustgrave’s picture

Status: Needs review » Needs work

Now it actually does need a rebase.

shalini_jha made their first commit to this issue’s fork.

shalini_jha’s picture

Status: Needs work » Needs review

I have rebased the MR, resolved the conflict, and followed the steps outlined in #14. I have also verified the PHP Stan baseline. Since the pipeline is now green, Checked the threads , but nothing open so moving this back to 'Needs Review'.

smustgrave’s picture

Status: Needs review » Needs work

Needs a rebase.

shalini_jha’s picture

I am working on it

shalini_jha’s picture

Status: Needs work » Needs review

Rebase & fixed conflict,moving this NR.

smustgrave’s picture

Status: Needs review » Reviewed & tested by the community

This rebase seems to hold for now.

quietone’s picture

Status: Reviewed & tested by the community » Needs work

Sorry, needs another rebase.

shalini_jha’s picture

Status: Needs work » Needs review

Rebased this without encountering any conflicts

smustgrave’s picture

Status: Needs review » Needs work
Issue tags: +Needs Review Queue Initiative

Sorry still needs a rebase

If you are another contributor eager to jump in, please allow the previous poster at 8 hours to respond to feedback first, so they have the opportunity to finish what they started!

shalini_jha’s picture

Status: Needs work » Needs review

Rebased & fixed conflicts :)

Anonymous’s picture

The rebase seems to hold for now
Can be moved to RTBC now, i worked on this issue so cant move it to RTBC, will wait for someone else to RTBC this.

smustgrave’s picture

Status: Needs review » Reviewed & tested by the community

Thanks @shalini_jha!

quietone’s picture

Before applying the diff these are the info hooks with a return type. The void agrees with the Issue Summary.

(11.x)$ git grep -A1  "#\[Hook.*_info')"  | grep \):
core/modules/config_translation/src/Hook/ConfigTranslationHooks.php-  public function configTranslationInfo(&$info): void {
core/modules/file/src/Hook/TokenHooks.php-  public function tokenInfo(): array {
core/modules/system/tests/modules/plugin_test/src/Hook/PluginTestHooks.php-  public function testPluginInfo(): array {
core/modules/workspaces/src/Hook/EntityTypeInfo.php-  public function entityBaseFieldInfo(EntityTypeInterface $entity_type): array {

After applying the diff and search for info hooks with an array return, there is just the config one, as expected.

 (11.x)$ git grep -A1  "#\[Hook.*_info')"  | grep function | grep -v ": array"
core/modules/config_translation/src/Hook/ConfigTranslationHooks.php-  public function configTranslationInfo(&$info): void {
quietone’s picture

Status: Reviewed & tested by the community » Fixed

Committed 873f84f and pushed to 11.x. Thanks!

  • quietone committed 873f84fc on 11.x
    Issue #3488841 by mstrelan, shalini_jha, akulsaxena, smustgrave, nicxvan...
quietone’s picture

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

nicxvan’s picture