Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect return type if null translation #45

Open
nathanczachur opened this issue May 19, 2021 · 1 comment
Open

Incorrect return type if null translation #45

nathanczachur opened this issue May 19, 2021 · 1 comment

Comments

@nathanczachur
Copy link

nathanczachur commented May 19, 2021

First, thanks for a great package! This has saved me a lot of time!

I have found a bug with incorrect return types. I will look into it myself, but wanted to start the issue here.

File: src/Api/StichozaApiTranslate.php:30

StichozaApiTranslate->translate has a return type of string. But the GoogleTranslate->handle can return null or string (See method return type)

Also, the StichozaApiTranslate->translate returns false in the try catch. This will break at some point too.

Do you think we should go for: If a translation cannot be found for whatever reason, is the expected behaviour to return null instead of a string?

@nathanczachur
Copy link
Author

The specific translation I have is an empty string:
Screenshot 2021-05-19 at 13 31 50

This is the only line that fails, which is likely why GoogleTranslate returned null instead of a string.

itsrexb referenced this issue in itsrexb/laravel-google-translate Dec 9, 2022
…e::translate(): Return value must be of type string, null returned (Most recent call first)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant