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

null is not an instance of stdClass #7

Closed
lausek opened this issue Dec 30, 2019 · 4 comments
Closed

null is not an instance of stdClass #7

lausek opened this issue Dec 30, 2019 · 4 comments

Comments

@lausek
Copy link
Contributor

lausek commented Dec 30, 2019

Client->getUpdate() could return null through json_decode which leads to this fatal error:

Fatal error: Uncaught TypeError: Return value of TuriBot\Client::getUpdate() must be 
an instance of stdClass, null returned in turibot/src/Client.php:46

PHP version: 7.3.13
Possible solution: Add nullable or remove type hint

lausek added a commit to lausek/TuriBot that referenced this issue Dec 30, 2019
@davtur19
Copy link
Owner

I could do a fix as you say, but the problem would remain, it should not return null.
Can you understand why the json decode goes wrong?
You may have this problem
If you can, see with json_last_error what error it gives you

@lausek
Copy link
Contributor Author

lausek commented Dec 30, 2019

No, I'm just calling the hook by myself so the input stream is empty. Anyways, the function should not panic.

What would be the value of getUpdate if the decoding wasn't successful?

@davtur19
Copy link
Owner

The return value of getUpdate could simply be a null, what do you think about it?

@lausek
Copy link
Contributor Author

lausek commented Dec 30, 2019

Yeah, think so too. That's why I created a pull request.

davtur19 added a commit that referenced this issue Dec 30, 2019
davtur19 added a commit that referenced this issue Dec 30, 2019
fix issue #7
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