Lots of PHPCS fixes

Got bored this weekend, decided to start fixing PHPCS errors on top of @localheinz pull request #6182
This could have been splitted fixed without relying on a local variable.