Static methods throwing exception

Issue #1 resolved
Matthias Zaunseder created an issue

Hi, if I try to use the static method "Json::decode" it throws this exception: "Non-static method Hampel\Json\Json::decode() should not be called statically". According to this SO answer the __callStatic magic method is just called if the static methods are not accessible, but decode and encode are public. As a fast workaround I use (new Json())->decode().

I would appreciate it if you could look into this problem. Thanks!

Comments (5)

  1. Simon Hampel repo owner
    • changed status to open

    After spending the day working through a bug in phpbrew so I could do testing on multiple versions of PHP, I have finally been able to get PHP 5.4.12 working on my machine - and I can confirm this error you are seeing.

    I will investigate further and try and find a fix.

  2. Simon Hampel repo owner

    I was able to confirm that no version of PHP 5.4 worked with the way I was using __callStatic, so I figured it was simply easier to just make the functions static and be done with it.

    Interestingly, I was not able to find any documentation which described the change in behaviour that made it work in PHP 5.5.

    Either way, I've now created versions of this package specifically for PHP 5.3, PHP 5.4 and PHP 5.5 ... if you are requiring "hampel/json": "~2.0", you should theoretically get the most appropriate version for you depending on your PHP version (in your case, v2.2.x for PHP 5.4.x)

  3. Log in to comment