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

Invalid argument supplied for foreach() #124

Closed
ilumos opened this issue Oct 10, 2021 · 2 comments
Closed

Invalid argument supplied for foreach() #124

ilumos opened this issue Oct 10, 2021 · 2 comments

Comments

@ilumos
Copy link
Contributor

ilumos commented Oct 10, 2021

Hey folks,

When calling Steam::app()->appDetails(1444140) I get the error:

ErrorException

 Invalid argument supplied for foreach()

 at vendor/syntax/steam-api/src/Syntax/SteamApi/Steam/App.php:79
   75|     protected function convertGames($apps)
   76|     {
   77|         $convertedApps = new Collection();
   78|
 > 79|         foreach ($apps as $app) {
   80|             if (isset($app->data)) {
   81|                 $convertedApps->add(new AppContainer($app->data));
   82|             }
   83|         }

I expect this is because Steam's API is returning an empty response with HTTP 200 OK.

Would it be appropriate to check for an empty response in setUpClient and if one is found, throw an ApiCallFailedException?

If so I will submit a PR.

Thank you for your great library!

@ilumos
Copy link
Contributor Author

ilumos commented Nov 4, 2021

Looks like other endpoints sometimes return empty responses too:

#121

Where would be a good place to check for an empty response and throw an exception?

@nicekiwi
Copy link
Collaborator

I think this is covered in 3.0.0 release, will reopen if it keep happening.

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

2 participants