Updated implementation to match PHP 5.5.0.