-
Notifications
You must be signed in to change notification settings - Fork 136
/
runkit_methods_redefining_and_cache.phpt
98 lines (88 loc) · 1.97 KB
/
runkit_methods_redefining_and_cache.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
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
--TEST--
Test for caching issues on redefining class methods
--SKIPIF--
<?php
if(!extension_loaded("runkit") || !RUNKIT_FEATURE_MANIPULATION) print "skip";
?>
--INI--
error_reporting=E_ALL
display_errors=on
--FILE--
<?php
class RunkitClass {
function a() {
}
}
class Test {
var $obj;
function a($result) {
for ($i = 0; $i < 10; $i++) {
runkit_method_redefine('RunkitClass', 'a', '', "echo ''; return $result + 1;");
$result = $this->obj->a($result);
}
return $result;
}
function b($result) {
for ($i = 0; $i < 10; $i++) {
runkit_method_remove('RunkitClass', 'a');
runkit_method_add('RunkitClass', 'a', '', "echo ''; return $result + 1;");
$result = $this->obj->a();
}
return $result;
}
function c($result) {
for ($i = 0; $i < 10; $i++) {
runkit_import('runkit_methods_redefining_and_cache.inc', RUNKIT_IMPORT_CLASSES | RUNKIT_IMPORT_OVERRIDE);
$result = $this->obj->a($result);
}
return $result;
}
function t() {
$this->obj = new RunkitClass();
$result = 0;
for ($i = 0; $i < 10; $i++) {
$result = $this->a($result);
}
echo $result, "\n";
for ($i=0; $i<10; $i++) {
$result = $this->b($result);
}
echo $result, "\n";
for ($i=0; $i<10; $i++) {
$result = $this->c($result);
}
echo $result, "\n";
}
}
$t = new Test();
$t->t();
$obj = new RunkitClass();
function a($result, $obj) {
for ($i = 0; $i < 10; $i++) {
runkit_method_redefine('RunkitClass', 'a', '', "echo ''; return $result + 1;");
$result = $obj->a();
}
return $result;
}
$result = 300;
for ($i = 0; $i < 10; $i++) {
$result = a($result, $obj);
}
echo $result, "\n";
function b($result, $obj) {
for ($i = 0; $i < 10; $i++) {
runkit_method_redefine('RunkitClass', 'a', '', "echo ''; return $result + 1;");
$result = $obj->a();
}
return $result;
}
for ($i = 0; $i < 10; $i++) {
$result = b($result, $obj);
}
echo $result, "\n";
--EXPECT--
100
200
300
400
500