fix regressions for php <5.4 (credits @brentonstrine)