Add type hinting to functions

It's only reasonable to have proper type hinting here which might even help us to catch bugs.
Fix PHPDoc and remove explicit type hint
drop unneeded hint
Merge pull request #11760 from owncloud/add-type-hints-where-sensible

Add type hinting to functions