Code style fixes

A whole bundle of coding style fixes to bring code closer in line with [PSR-1](http://www.php-fig.org/psr/psr-1/) and [PSR-2](http://www.php-fig.org/psr/psr-2/), mostly automated using http://cs.sensiolabs.org/. These changes do *not* include any alterations to the functional behaviour of the code, and are entirely cosmetic (with the possible exception of visibility declarations, which are now explicitly `public` where it was previously implicit).