public static void closeStream(Environment env, InputStream inputStream){
        if (inputStream instanceof FileInputStream
                || (inputStream instanceof StreamInputStream && ((StreamInputStream) inputStream).autoClose))
            try {
                inputStream.close();
            } catch (IOException e) {
                env.exception(WrapIOException.class, e.getMessage());
            }
    }
@param arg - File path or Stream object
@return
jphp-runtime/src/php/runtime/ext/core/classes/stream/Stream.java