PHP port of mourner/simplify-js