diff --git a/jphp-runtime/src/php/runtime/ext/core/classes/stream/Stream.java b/jphp-runtime/src/php/runtime/ext/core/classes/stream/Stream.java index ec5bb3e85..1729ecee7 100644 --- a/jphp-runtime/src/php/runtime/ext/core/classes/stream/Stream.java +++ b/jphp-runtime/src/php/runtime/ext/core/classes/stream/Stream.java @@ -5,7 +5,6 @@ import php.runtime.common.Messages; import php.runtime.common.Modifier; import php.runtime.env.Environment; -import php.runtime.env.TraceInfo; import php.runtime.lang.BaseObject; import php.runtime.lang.Resource; import php.runtime.memory.BinaryMemory; @@ -109,20 +108,8 @@ public void setMode(String mode) { @Signature abstract public Memory close(Environment env, Memory... args) throws IOException; - public static Stream create(Environment env, TraceInfo trace, String path, String mode) throws Throwable { - String protocol = "file"; - int pos = path.indexOf("://"); - if (pos > -1) { - protocol = path.substring(0, pos); - path = path.substring(pos + 3); - } - - ClassEntity classEntity = env.getUserValue(Stream.class.getName() + "#" + protocol, ClassEntity.class); - if (classEntity == null){ - return null; - } - - return (Stream)classEntity.newObject(env, trace, true, new StringMemory(path), new StringMemory(mode)); + public static Stream create(Environment env, String path, String mode) throws Throwable { + return of(env, StringMemory.valueOf(path), StringMemory.valueOf(mode)).toObject(Stream.class); } @Signature({@Arg("path"), @Arg(value = "mode", optional = @Optional("r"))}) diff --git a/jphp-zend-ext/src/main/java/org/develnext/jphp/zend/ext/standard/FileFunctions.java b/jphp-zend-ext/src/main/java/org/develnext/jphp/zend/ext/standard/FileFunctions.java index 4d8061344..54daa5abf 100644 --- a/jphp-zend-ext/src/main/java/org/develnext/jphp/zend/ext/standard/FileFunctions.java +++ b/jphp-zend-ext/src/main/java/org/develnext/jphp/zend/ext/standard/FileFunctions.java @@ -71,7 +71,7 @@ public static boolean chown(String fileName, String owner){ } public static boolean copy(Environment env, TraceInfo trace, String source, String dest) throws Throwable { - Stream stream = Stream.create(env, trace, source, "r"); + Stream stream = Stream.create(env, source, "r"); if (stream == null) { env.warning("copy(): Invalid source path"); return false; @@ -136,7 +136,7 @@ public static Memory file(Environment env, TraceInfo trace, String path) throws public static Memory file(Environment env, TraceInfo trace, String path, int flags, Memory context) throws Throwable { Stream stream = null; try { - stream = Stream.create(env, trace, path, "r"); + stream = Stream.create(env, path, "r"); if (stream == null){ env.warning(trace, "file(): failed to open stream"); return Memory.FALSE; @@ -188,7 +188,7 @@ public static Memory file_get_contents(Environment env, TraceInfo trace, String Memory context, Memory offset, Memory maxLength) throws Throwable { Stream stream = null; try { - stream = Stream.create(env, trace, path, "r"); + stream = Stream.create(env, path, "r"); if (stream == null){ env.warning(trace, "file_get_contents(): failed to open stream"); return Memory.FALSE; @@ -243,7 +243,7 @@ public static Memory file_put_contents(Environment env, TraceInfo trace, String if ((flags & FileConstants.FILE_APPEND) == FileConstants.FILE_APPEND) mode = "a"; - stream = Stream.create(env, trace, path, mode); + stream = Stream.create(env, path, mode); if (stream == null){ env.warning(trace, "file_put_contents(): failed to open stream"); return Memory.FALSE;