Fix multiple code style warnings

* `assertHasKey` is used in a subclass. Obviously this bit of code was never executed (would have been failed horribly). But I don't think I can remove it.
* Some of the `@var` hints did the opposite and created extra warnings. Relying on the `instanceof` checks is fine.