Skip to content

Commit f0a5a0a

Browse files
committed
Fix Error.$trace property.
1 parent b12c4ac commit f0a5a0a

File tree

3 files changed

+29
-28
lines changed

3 files changed

+29
-28
lines changed

jphp-runtime/src/php/runtime/common/HintType.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
package php.runtime.common;
22

3-
import php.runtime.common.collections.map.HashedMap;
4-
53
import java.util.HashMap;
64
import java.util.Map;
75

@@ -35,7 +33,7 @@ public String toString(){
3533
}
3634
}
3735

38-
public static HintType of(String code){
36+
public static HintType of(String code) {
3937
return values.get(code);
4038
}
4139
}

jphp-runtime/src/php/runtime/ext/core/classes/stream/FileStream.java

Lines changed: 27 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -45,50 +45,53 @@ public Memory __construct(Environment env, Memory... args) throws IOException {
4545
super.__construct(env, args);
4646

4747
try {
48-
if (getMode().equals("r")) {
49-
accessFile = new RandomAccessFile(getPath(), "r");
48+
String mode = getMode();
49+
String path = getPath();
50+
51+
if (mode.equals("r") || mode.equals("rb")) {
52+
accessFile = new RandomAccessFile(path, "r");
5053
position = 0;
51-
} else if (getMode().equals("r+")){
52-
if (!new File(getPath()).getAbsoluteFile().exists())
54+
} else if (mode.equals("r+") || mode.equals("rb+")){
55+
if (!new File(path).getAbsoluteFile().exists())
5356
throwFileNotFound(env);
54-
accessFile = new RandomAccessFile(getPath(), "rw");
55-
} else if (getMode().equals("w")){
56-
accessFile = new RandomAccessFile(getPath(), "rw");
57+
accessFile = new RandomAccessFile(path, "rw");
58+
} else if (mode.equals("w") || mode.equals("wb")){
59+
accessFile = new RandomAccessFile(path, "rw");
5760
accessFile.setLength(0);
5861
canRead = false;
59-
} else if (getMode().equals("w+")){
60-
accessFile = new RandomAccessFile(getPath(), "rw");
62+
} else if (mode.equals("w+") || mode.equals("wb+")){
63+
accessFile = new RandomAccessFile(path, "rw");
6164
accessFile.setLength(0);
62-
} else if (getMode().equals("a")){
63-
accessFile = new RandomAccessFile(getPath(), "rw");
64-
File file = new File(getPath());
65+
} else if (mode.equals("a")){
66+
accessFile = new RandomAccessFile(path, "rw");
67+
File file = new File(path);
6568
if (file.getAbsoluteFile().exists()) {
6669
accessFile.seek(file.length());
6770
position = file.length();
6871
}
6972

7073
canRead = false;
71-
} else if (getMode().equals("a+")){
72-
accessFile = new RandomAccessFile(getPath(), "rw");
73-
File file = new File(getPath());
74+
} else if (mode.equals("a+")){
75+
accessFile = new RandomAccessFile(path, "rw");
76+
File file = new File(path);
7477
if (file.getAbsoluteFile().exists()){
7578
accessFile.seek(file.length());
7679
position = file.length();
7780
}
78-
} else if (getMode().equals("x") || getMode().equals("x+")){
79-
File file = new File(getPath());
81+
} else if (mode.equals("x") || mode.equals("x+")){
82+
File file = new File(path);
8083
if (file.getAbsoluteFile().exists())
81-
env.exception(WrapIOException.class, "File '%s' already exists (mode: %s)", getMode());
84+
env.exception(WrapIOException.class, "File '%s' already exists (mode: %s)", mode);
8285

83-
accessFile = new RandomAccessFile(getPath(), "rw");
84-
if (getMode().equals("x"))
86+
accessFile = new RandomAccessFile(path, "rw");
87+
if (mode.equals("x"))
8588
canRead = false;
86-
} else if (getMode().equals("c") || getMode().equals("c+")){
87-
accessFile = new RandomAccessFile(getPath(), "rw");
88-
if (getMode().equals("c"))
89+
} else if (mode.equals("c") || mode.equals("c+")){
90+
accessFile = new RandomAccessFile(path, "rw");
91+
if (mode.equals("c"))
8992
canRead = false;
9093
} else
91-
env.exception(WrapIOException.class, "Unsupported mode - '%s'", getMode());
94+
env.exception(WrapIOException.class, "Unsupported mode - '%s'", mode);
9295
} catch (FileNotFoundException e){
9396
throwFileNotFound(env);
9497
} catch (IOException e) {

jphp-runtime/src/php/runtime/lang/exception/BaseError.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
@Reflection.Arg(value = "message", modifier = Modifier.PROTECTED, type = HintType.STRING),
2222
@Reflection.Arg(value = "code", modifier = Modifier.PROTECTED, type = HintType.INT),
2323
@Reflection.Arg(value = "previous", modifier = Modifier.PROTECTED, type = HintType.OBJECT),
24-
@Reflection.Arg(value = "trace", modifier = Modifier.PROTECTED, type = HintType.ARRAY),
24+
@Reflection.Arg(value = "trace", modifier = Modifier.PRIVATE, type = HintType.ARRAY),
2525
@Reflection.Arg(value = "file", modifier = Modifier.PROTECTED, type = HintType.STRING),
2626
@Reflection.Arg(value = "line", modifier = Modifier.PROTECTED, type = HintType.INT),
2727
@Reflection.Arg(value = "position", modifier = Modifier.PROTECTED, type = HintType.INT)

0 commit comments

Comments
 (0)