function someMethod(): string
{
return trans('my.translation.key');
}
Method someMethod should return string but returns array|Illuminate\Contracts\Translation\Translator|string|null.
The return type Illuminate\Contracts\Translation\Translator can be fixed by a patch to HelpersReturnTypeExtension(?), but it will still fail because of array cannot be converted to a string.
The return type
Illuminate\Contracts\Translation\Translator
can be fixed by a patch toHelpersReturnTypeExtension
(?), but it will still fail because of array cannot be converted to a string.Ideas:
1) Use a wrapper method:
This will make trans() autocompletion no longer work in PHPStorm
force_string(trans('my.translation.key'));