Problem/Motivation

Several preprocess hook implementations in core themes define the `$variables` parameter without an explicit type declaration (e.g., `&$variables`).

Adding explicit `array` type hints improves developer experience and aligns with Drupal’s move toward stricter typing.

Steps to reproduce

NA

Proposed resolution

Add `array` type hints to all preprocess hook method parameters where `$variables` (and similar parameters like `$form`, `$suggestions`, `$info`) are expected to be arrays.

Remaining tasks

Combine #3579925: Add missing type hint for $variables parameter in ClaroHooks.php

User interface changes

NA

Introduced terminology

NA

API changes

Method signatures for hook implementations are updated to include stricter parameter type declarations.

Issue fork drupal-3579922

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

sivaji_ganesh_jojodae’s picture

Issue summary: View changes
debdeep.mukhopadhyay’s picture

I am working on this.

nicxvan’s picture

Title: Add missing type hint for $variables parameter in OliveroHooks.php » [pp-]Add missing type hint for $variables parameter in OliveroHooks.php
Status: Active » Postponed
Issue tags: -Add missing type hint for $variables parameter

Thank you, this needs to be postponed I think on the remaining conversion.

sivaji_ganesh_jojodae’s picture

Issue summary: View changes
sivaji_ganesh_jojodae’s picture

Thank you for updating the issue appropriately. It would be helpful to link the blocking parent issue here for easier tracking and follow-up.

nicxvan’s picture

Title: [pp-]Add missing type hint for $variables parameter in OliveroHooks.php » [pp-1] Add missing type hint for $variables parameter in OliveroHooks.php
Issue summary: View changes
sivaji_ganesh_jojodae’s picture

Status: Postponed » Active
sivaji_ganesh_jojodae’s picture

Assigned: Unassigned » sivaji_ganesh_jojodae

Working on this.

nicxvan’s picture

Title: [pp-1] Add missing type hint for $variables parameter in OliveroHooks.php » Add missing type hint for $variables parameter in OliveroHooks.php

sivaji_ganesh_jojodae’s picture

Status: Active » Needs review
smustgrave’s picture

Is this something that we actually need to do? if so think it's so minor should expand scope to other themes.

smustgrave’s picture

Status: Needs review » Needs work
sivaji_ganesh_jojodae’s picture

Assigned: sivaji_ganesh_jojodae » Unassigned
Status: Needs work » Needs review

If the intention is to merge issues, the issue metadata (title, component, and summary) should be updated accordingly to reflect the combined scope. Inappropriate or inconsistent updates can make it harder for potential reviewers to understand the issue and may lead to it being overlooked or misinterpreted.

I would refrain from updates that do not align with the original scope or that disregard the interest of other participants in this issue.

smustgrave’s picture

Title: Add missing type hint for $variables parameter in OliveroHooks.php » Add missing type hint for $variables parameter in theme hooks
Status: Needs review » Needs work
Issue tags: +Needs issue summary update

You are correct. I went ahead and did the title.

Again this is just adding arrays. Nothing complex so reviews are not complex. This really should of been a novice task for first time users but what's done is done. Lets combine.

smustgrave’s picture

Issue tags: +Novice

In case a new user wants to combine.

smustgrave’s picture

Issue summary: View changes
Issue tags: -Needs issue summary update

Fixed the summary for you, removing the AI stuff.

smustgrave’s picture

Posted in #first-contribution if you don’t happen to get to it.

Thanks

sivaji_ganesh_jojodae’s picture

It seems like the recent updates are moving toward a “process as proxy” approach.

Both issues already had the necessary PRs in place and were quite close to RTBC and being marked as fixed. Some of the recent metadata changes appear redundant and only moving the issue backward rather than helping it progress.

In particular, the updates in #3578084: Add return types to Twig implementations reverts change from my PR, which sounds rude and difficult to follow the direction of the issue and continue contributing effectively. It would be helpful to better understand how much autonomy contributors are expected to exercise in such cases.

For those continuing work on this issue, you can apply the changes from #3579925: Add missing type hint for $variables parameter in ClaroHooks.php using:

git cherry-pick 9ffc6e69a76f81241b00dadd3c82f89f1fafe709

nicxvan’s picture

@sivaji_ganesh_jojodae I understand it can sometimes be frustrating.

Determining the right scope in core can be complex.

The twig issue had a very targeted scope so adding more return types could be problematic if it had to be reverted so it's better to be tightly scoped.

This and the claro hooks are nearly identical and easy to review so they should be combined.

The good news is you can just apply the claro hook diff to this branch.

I would also look for the test modules and update the typing there too.

If you have further questions the #core-development channel in slack is a great place to discuss scoping issues.

We are always trying to balance the number of issues and the scope so it's not always easy to get correct when creating issues.

sivaji_ganesh_jojodae’s picture

@nicxvan, thanks for the clarification, I appreciate the context. And thanks as well for pointing to the Slack channel — I’ll keep that in mind for discussing scope-related questions going forward.

sivaji_ganesh_jojodae’s picture

Status: Needs work » Needs review

I've git cherry picked the changes from #3579925: Add missing type hint for $variables parameter in ClaroHooks.php and rebased.

rohansingh20201@gmail.com made their first commit to this issue’s fork.

smustgrave’s picture

Status: Needs review » Reviewed & tested by the community

Think this one is fine to go.

alexpott’s picture

Version: main » 11.3.x-dev
Status: Reviewed & tested by the community » Fixed

Committed and pushed 387533dfcef to main and 8e3d0e2e6d8 to 11.x. Thanks!

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

  • alexpott committed 8e3d0e2e on 11.x
    task: #3579922 Add missing type hint for $variables parameter in theme...

  • alexpott committed 387533df on main
    task: #3579922 Add missing type hint for $variables parameter in theme...

Status: Fixed » Closed (fixed)

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