added support for returning object in new overload

This solution is very hacky due to a few copy&pastes from zend code base.
Anyone with more experience in writing php extensions could help to clean it up.