-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathautocompleting-proxy.php
44 lines (37 loc) · 1.06 KB
/
autocompleting-proxy.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
<?php
/**
* @property int $one
* @property int $some
* @method int get_one()
* @method int get_some()
* @method int set_some(int $param)
*/
final class MyInstanceProxy {
private readonly Wasm\WasmInstance $proxy;
public function __construct() {
$this->proxy = Wasm\InstanceBuilder::fromWat(
<<<'EOWAT'
(module
(global $one (export "one") i32 (i32.const 1))
(global $some (export "some") (mut i32) (i32.const 0))
(func (export "get_one") (result i32) (global.get $one))
(func (export "get_some") (result i32) (global.get $some))
(func (export "set_some") (param i32) (global.set $some (local.get 0))))
EOWAT
)->build();
}
public function __call(string $name, array $args): mixed
{
return $this->proxy->__call($name, $args);
}
public function __get(string $name): mixed
{
return $this->proxy->__get($name);
}
public function __set(string $name, mixed $value): void
{
$this->proxy->__set($name, $$value);
}
}
$instance = new \MyInstanceProxy();
var_dump($instance->some);