forked from krakjoe/pthreads
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcomplex-statics-set-null.phpt
64 lines (57 loc) · 1.21 KB
/
complex-statics-set-null.phpt
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
--TEST--
Test NULLing ressources in arrays
--FILE--
<?php
class file {
public static $fps;
public static function __callstatic($method, $args) {
$tid = Thread::getCurrentThreadId();
if (isset(self::$fps[$tid])) {
return call_user_func_array(array("file", "_{$method}"), array_merge($args, array($tid)));
} else {
self::$fps[$tid] = fopen(__FILE__, "r+");
if (isset(self::$fps[$tid]))
return call_user_func_array(array("file", "_{$method}"), array_merge($args, array($tid)));
}
}
public static function _get ($arg, $tid) {
printf("%s: %s\n", __METHOD__, $arg);
var_dump(self::$fps);
}
}
class UserThread extends Thread {
public function run () {
/* execute calls */
$i = 2;
file::get("something".(++$i));
file::get("something".(++$i));
}
}
$i = 0;
file::get("something".(++$i));
file::get("something".(++$i));
$thread = new UserThread();
$thread->start();
$thread->join();
?>
--EXPECTF--
file::_get: something1
array(1) {
[%i]=>
resource(5) of type (stream)
}
file::_get: something2
array(1) {
[%i]=>
resource(5) of type (stream)
}
file::_get: something3
array(1) {
[%i]=>
resource(2) of type (stream)
}
file::_get: something4
array(1) {
[%i]=>
resource(2) of type (stream)
}