PHPStan Level 5
Summary: Mostly type related changes, but it actually found one bug
Test Plan: ./phpunit
Reviewers: #hkccp_developers, mollekopf
Reviewed By: #hkccp_developers, mollekopf
Subscribers: #hkccp_developers
Differential Revision: https://git.kolab.org/D4622