Fix #39, Fix #38

+ minor PHPDoc additions for better type hinting
+ fix CS
Backport fix for #38 and #39 from 1.3
Merge branch '1.2'
Fix for #41 and a relevant unit test