General type hint cleanup

* Added and fixed some type hints.
* PHPStorm understands `[]` but not `[][]`.
* Calling magic methods like `__toString` is weird should not be done.
* Optimized all imports.