## 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.
Issue fork recipe_installer_kit-3564823
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
Comment #4
phenaproximaTo 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
mixedreturn type hint (be sure to update the method's doc comment to match) and left everything else as-is.Comment #5
sujal kshatri commentedthat makes sense
Should I make changes like:-
Before-
After -
Is this good?
Comment #6
phenaproximaThat looks pretty good to me!
Comment #8
phenaproximaMerged into 1.x and released in version 1.0.1. Thanks!