forked from swoole/yasd
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.php
110 lines (88 loc) · 1.56 KB
/
test.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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
<?php
use Swoole\Coroutine;
use function Swoole\Coroutine\run;
function test1() {
echo 'test1' . PHP_EOL;
test2();
}
function test2() {
return;
echo 'test2' . PHP_EOL;
}
class Foo3
{
public $a;
private $c;
public function __construct()
{
$this->a = "hello";
$this->c = ['a', 'b'];
}
}
class Foo2
{
public $a;
private $foo3;
/**
* Map of entries that are already resolved.
*
* @var array
*/
private $resolvedEntries = [];
public function __construct()
{
$this->a = "hello";
$this->resolvedEntries = [
'aaa' => new Foo3(),
'bbb' => [4, 5, 6],
];
$this->foo3 = new Foo3();
}
}
class Foo
{
public $a;
public $foo2;
public function __construct($a)
{
$this->a = "hello";
$this->foo2 = new Foo2();
}
}
$b = true;
$b = false;
$i = 0;
$j = 1;
$j = 2;
$k = [];
$k = ['a' => ['b' => [1, 2, 3]]];
while (true) {
if ($i++ == 5) {
$k = ['hello' => 1, "world" => 1.1];
$j = 5;
}
if ($i == 10) {
$k = ['hello', 'world'];
$j = 10;
break;
}
}
echo 'hello' . PHP_EOL;
require __DIR__ . '/header.php';
echo 'world' . PHP_EOL;
$foo = new Foo(2);
run(function () {
Coroutine::create(function () {
$i = 1;
test1();
Coroutine::yield();
$i = 2;
$a = ['a' => 1, 'b' => 2];
var_dump($a);
});
Coroutine::create(function () {
$i = 3;
Coroutine::resume(2);
$i = 4;
});
});