Check for NULL ptr from get_stream() before passing it on to php_stream_cast()