Make extension compatible with latest PHP versions

fixes #15

Not sure if this approach is correct as I don't have much experience with C and PHP internals. At least this patch fixes the PHP test suite with `scalar_objects` extension enabled.