Backport 7728

There were some merge conflicts, so I send a pr instead of just backporting it. 

backport of https://github.com/owncloud/core/pull/7728

please review @PVince81 @scolebrook 
Missing PHPDoc