PSR-2 Reformatting and PHPDoc corrections

This is a bit of a monster...

The PSR-2 reformatting was done with a mixture of [Sensio's php-cs-fixer](http://cs.sensiolabs.org) followed by more automated formatting and hand-editing of layout and phpdocs in PHPStorm.

With all the phpdoc changes, everything springs to life in IDEs that do static analysis, auto-completion and type checking. In a few places it took quite a bit of detective work to figure out what types things should be. Sometimes I couldn't work it out, and I've added 'fix type' todos in those places.

Ther are some very minor code changes - a couple of deleted unused local vars.

I've not attempted to address PSR-0 issues with name spacing, composer etc - there are plenty of forks that have.

There's an awful lot of code in here, and I've learned a lot by going through it such detail.

Tests are passing. Time for some sleep!