Fix code to work with PHP 5.3

Fixes #1117.