The _map_handle_ approach could possibly work, but the handle of the PHP object at map->outputformat would be invalid (since it would still refer to the original outputFormatObj C struct).
Perhaps a cleaner fix would be to destroy the map->outputformat PHP object (which is a PHP wrapper with a ref to the C struct with a stub destructor that does nothing) and create a new one in php3_ms_map_selectOutputFormat() using _phpms_build_outputformat_object()? I don't think we do that kind of stuff anywhere yet, but this way the handle would be maintained properly.