Skip to content

Commit 52e962f

Browse files
committed
Upgrade jppm.
1 parent ac33ebf commit 52e962f

File tree

6 files changed

+55
-21
lines changed

6 files changed

+55
-21
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
package php.runtime.memory.support.operation;
2+
3+
public class ReaderMemoryStream {
4+
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
package php.runtime.memory.support.operation;
2+
3+
import php.runtime.Memory;
4+
import php.runtime.env.Environment;
5+
import php.runtime.env.TraceInfo;
6+
import php.runtime.exceptions.CriticalException;
7+
import php.runtime.ext.core.classes.stream.FileObject;
8+
import php.runtime.ext.core.classes.stream.Stream;
9+
import php.runtime.memory.support.MemoryOperation;
10+
11+
import java.io.*;
12+
13+
public class ReaderMemoryStream extends MemoryOperation<Reader> {
14+
@Override
15+
public Class<?>[] getOperationClasses() {
16+
return new Class[] { Reader.class };
17+
}
18+
19+
@Override
20+
public Reader convert(Environment env, TraceInfo trace, Memory arg) throws Throwable {
21+
if (arg.isNull()) return null;
22+
23+
if (arg.instanceOf(Stream.class)) {
24+
InputStream inputStream = Stream.getInputStream(env, arg);
25+
if (inputStream == null) return null;
26+
27+
return new InputStreamReader(inputStream, env.getDefaultCharset());
28+
} else if (arg.instanceOf(FileObject.class)) {
29+
Stream stream = Stream.create(env, arg.toString(), "r");
30+
return new InputStreamReader(Stream.getInputStream(env, stream), env.getDefaultCharset());
31+
}
32+
33+
return new StringReader(arg.toString());
34+
}
35+
36+
@Override
37+
public Memory unconvert(Environment env, TraceInfo trace, Reader arg) throws Throwable {
38+
throw new CriticalException("Unsupported operation");
39+
}
40+
}

packager/example/hello-world/package.php.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,5 @@ app:
2525
sources:
2626
- src
2727

28+
includes:
29+
- index.php
Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,3 @@
11
<?php
22

3-
$t = \php\time\Time::millis();
4-
5-
function test($a, $b, $c = 33, $d = 22) {
6-
$x = $a * 2;
7-
$y = $b ^ 4;
8-
return $c + $d + 1 + $x - $y;
9-
}
10-
11-
echo \php\time\Time::millis() - $t, "ms";
12-
/*
13-
14-
$localPort = \php\net\ServerSocket::findAvailableLocalPort();
15-
$server = new \php\net\ServerSocket($localPort);
16-
17-
while (true) {
18-
$socket = $server->accept();
19-
}*/
3+
$password = "1fjhkldkjdlkj";

packager/package.php.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: jppm
2-
version: 0.6.5
2+
version: 0.6.6
33

44
plugins: [GitHub, Hub, Doc]
55

@@ -17,7 +17,7 @@ github:
1717
> JPHP Package Manager v%version%
1818
1919
**What's new**
20-
+ Fix app plugin bugs.
20+
+ Fix git sources and semver bugs.
2121
2222
**Downloads**
2323
+ For Windows: [JPPM Windows Installer](%github.address%/releases/download/jppm-%version%/jppm-setup-%version%.exe)

packager/src-php/packager/Repository.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -310,8 +310,12 @@ public function findPackage(string $name, string $versionPattern, ?PackageLock $
310310
$lockVersion = $lock->findVersion($name);
311311

312312
if ($lockVersion) {
313-
if ($lockVersion === $versionPattern || (new SemVersion($lockVersion))->satisfies($versionPattern)) {
314-
$versionPattern = $lockVersion;
313+
try {
314+
if ($lockVersion === $versionPattern || (new SemVersion($lockVersion))->satisfies($versionPattern)) {
315+
$versionPattern = $lockVersion;
316+
}
317+
} catch (\Throwable $e) {
318+
// nop.
315319
}
316320
}
317321
}

0 commit comments

Comments
 (0)