code cleanup

The 1st commit can be considered to be a bugfix because the wrong variable was used there, at least with my understanding of the code.

The 2nd commit removes unused variables while trying not to break stuff, as the code seems to be pretty fragile. There are still plenty of unused variables when calling methods in the manner of naming arguments like for `self::json_decode($value, $assoc = true)` where `$assoc` is in fact useless. I could remove them all as well.

The 3rd commit fixes the order of keywords in method signatures:
`static (public|protected|private) function` &rarr; `(public|protected|private) static function`.

Let me know what you think.
Maybe you could put this in a different pull request since it looks like it could fix a bug and is not just code cleanup?