NicklasWallgren / PokemonGoAPI-PHP

Pokemon Go API PHP library
BSD 2-Clause "Simplified" License
130 stars 51 forks source link

Fatal error: Call to a member function getType() on null #164

Closed baskettcase closed 7 years ago

baskettcase commented 7 years ago

Im getting this error and can't seem to get away from it.

Fatal error: Call to a member function getType() on null in /home/account/public_html/games/pokemongo/vendor/nicklasw/protobuf/php/src/Google/Protobuf/Internal/Message.php on line 319

This is for the RetrievePokemonTraitExample script,. The main difference I have between your example and what I did was I did this

$pokemons = $pokeBank->getPokemons()->sortByIVRatio(true);

Any ideas?

NicklasWallgren commented 7 years ago

I can't reproduce the problem. Could you provide me with additional details as well as the full stack trace?

baskettcase commented 7 years ago

How would I go about doing that since this is a fatal error?

NicklasWallgren commented 7 years ago

You can get hold of the trace using xdebug.

  1. Do any of the other examples work?
  2. What version of PHP are you running, 32bit or 64bit?
baskettcase commented 7 years ago

Ok I took a look at installing it and Im on a shared server so that wont work for xdebug. I tested the RetrievePokemonTraitExample without any of my modifications except for google/user/pass and I still get the same error.

I also tried GUI_BestCpPokemonDetails.php and I get the same error there also.

Im running 64 bit.

NicklasWallgren commented 7 years ago

I was able to reproduce the problem with a new account. The issue is due to a bug within the protocol buffer library https://github.com/google/protobuf

NicklasWallgren commented 7 years ago

https://github.com/google/protobuf/issues/2552

NicklasWallgren commented 7 years ago

Try updating the dependencies. I have hopefully fixed the issue in my fork of google/protobuf repo. You might get some notice messages, I'll fix them later.

https://github.com/NicklasWallgren/protobuf/commit/4f29e1337f40111494d2131dc613a3ab6ea94b8f

xmillies commented 7 years ago

It goes further.

Some notices in code

Notice: Undefined offset: 2 in C:\WTServer\WWW\pogo\vendor\nicklasw\protobuf\php\src\Google\Protobuf\descriptor.php on line 158 Notice: Undefined offset: 0 in C:\WTServer\WWW\pogo\vendor\nicklasw\protobuf\php\src\Google\Protobuf\descriptor.php on line 158 Notice: Undefined offset: 2 in C:\WTServer\WWW\pogo\vendor\nicklasw\protobuf\php\src\Google\Protobuf\descriptor.php on line 158 Notice: Undefined offset: 0 in C:\WTServer\WWW\pogo\vendor\nicklasw\protobuf\php\src\Google\Protobuf\descriptor.php on line 158 Notice: Undefined offset: 2 in C:\WTServer\WWW\pogo\vendor\nicklasw\protobuf\php\src\Google\Protobuf\descriptor.php on line 158 Notice: Undefined offset: 0 in C:\WTServer\WWW\pogo\vendor\nicklasw\protobuf\php\src\Google\Protobuf\descriptor.php on line 158 Notice: Undefined offset: 2 in C:\WTServer\WWW\pogo\vendor\nicklasw\protobuf\php\src\Google\Protobuf\descriptor.php on line 158 Notice: Undefined offset: 0 in C:\WTServer\WWW\pogo\vendor\nicklasw\protobuf\php\src\Google\Protobuf\descriptor.php on line 158 Notice: Undefined offset: 2 in C:\WTServer\WWW\pogo\vendor\nicklasw\protobuf\php\src\Google\Protobuf\descriptor.php on line 158 Notice: Undefined offset: 0 in C:\WTServer\WWW\pogo\vendor\nicklasw\protobuf\php\src\Google\Protobuf\descriptor.php on line 158 Notice: Undefined offset: 2 in C:\WTServer\WWW\pogo\vendor\nicklasw\protobuf\php\src\Google\Protobuf\descriptor.php on line 158 Notice: Undefined offset: 0 in C:\WTServer\WWW\pogo\vendor\nicklasw\protobuf\php\src\Google\Protobuf\descriptor.php on line 158 Notice: Undefined offset: 25 in C:\WTServer\WWW\pogo\vendor\nicklasw\protobuf\php\src\Google\Protobuf\descriptor.php on line 158 Notice: Undefined offset: 128787628 in C:\WTServer\WWW\pogo\vendor\nicklasw\protobuf\php\src\Google\Protobuf\descriptor.php on line 158 Warning: unpack() expects parameter 2 to be string, object given in C:\WTServer\WWW\pogo\web\update.php on line 104

Then

Fatal error: Uncaught Error: Call to undefined method POGOProtos\Enums\PokemonId::toString() in C:\WTServer\WWW\pogo\web\update.php:161 Stack trace: #0 C:\WTServer\WWW\pogo\web\update.php(570): MyPogo->updateDataFromNiantic('user', 'password', 'ptc', 'C:\\Users\\admin\\...') #1 {main} thrown in C:\WTServer\WWW\pogo\web\update.php on line 161

I will try with offcial samples.

xmillies commented 7 years ago

RetrievePokemonCandyCountExample.php works 👍

NicklasWallgren commented 7 years ago

The notice message has been suppressed as of 3.1.2 of google/protobuf.

The 'POGOProtos\Enums\PokemonId' class has been replaced with 'NicklasW\PkmGoApi\Api\Support\PokemonId'

And the 'toString' method is now called 'name'

PokemonId::name($id);

NicklasWallgren commented 7 years ago

Can we close this issue?

baskettcase commented 7 years ago

I get this now:

Fatal error: Call to undefined method POGOProtos\Inventory\AppliedItems::getItemArray() in /home/account/public_html/games/pokemongo/vendor/nicklasw/pkm-go-api/src/Api/Player/Data/Inventory/AppliedItems.php on line 44

NicklasWallgren commented 7 years ago

@baskettcase Fixed in https://github.com/NicklasWallgren/PokemonGoAPI-PHP/tree/v2.0.2

baskettcase commented 7 years ago

Awesome looks like it works now! It also looks like there are some strange things happening.. maybe a lot has changed. Ill look into it. Thanks again for getting this fixed!

NicklasWallgren commented 7 years ago

Resolved.