## Problem/Motivation

The `Hooks::downloadTranslations()` method in `src/Hooks.php` has a return type declaration of `?string`, but in Drupal 11, the core function `install_download_translation()` returns an `array`, causing a TypeError during site installation.

## Steps to reproduce

1. Use Recipe Installer Kit 1.0.0 with Drupal 11.x
2. Create a site installation profile using RecipeKit
3. Run site installation with a non-English language
4. The installation will fail with a TypeError

## Proposed resolution

The error occurs at line 206 in `src/Hooks.php`:

```php
return install_download_translation($install_state);
```

The Drupal 11 core function `install_download_translation()` returns an array, but the method signature expects `?string`.

**Suggested fix:**

```php
// Download core translations as normal.
$install_state['interactive'] = $was_interactive;
$result = install_download_translation($install_state);
// Drupal 11 returns array, but method signature expects ?string.
return is_array($result) ? NULL : $result;
```

This checks if the result is an array (as returned by Drupal 11) and returns NULL instead, which is compatible with the `?string` return type.

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

gloomcheng created an issue. See original summary.

sujal kshatri made their first commit to this issue’s fork.

phenaproxima’s picture

Status: Active » Needs work

To be honest, I don't really like the proposed fix. Since we are directly returning the output of a function we don't own, we shouldn't be making assumptions about what it will return. I'd prefer if we just used the mixed return type hint (be sure to update the method's doc comment to match) and left everything else as-is.

sujal kshatri’s picture

that makes sense
Should I make changes like:-

Before-

/**
 * @return string|null
 *   Output from `install_download_translation()`, if there was any.
 */
public static function downloadTranslations(array &$install_state): ?string {
  // ...
  return install_download_translation($install_state);
}

After -

/**
 * @return mixed
 *   Return value from `install_download_translation()`.
 */
public static function downloadTranslations(array &$install_state): mixed {
  // ...
  return install_download_translation($install_state);
}

Is this good?

phenaproxima’s picture

That looks pretty good to me!

phenaproxima’s picture

Status: Needs work » Fixed

Merged into 1.x and released in version 1.0.1. 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.

Status: Fixed » Closed (fixed)

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