This repository was archived by the owner on Mar 29, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathFunctionTemplate_callback_weakness.phpt
86 lines (69 loc) · 1.88 KB
/
FunctionTemplate_callback_weakness.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
--TEST--
V8\FunctionTemplate - callback weakness
--SKIPIF--
<?php if (!extension_loaded("v8")) print "skip"; ?>
--FILE--
<?php
/** @var \Phpv8Testsuite $helper */
$helper = require '.testsuite.php';
require '.v8-helpers.php';
$v8_helper = new PhpV8Helpers($helper);
$isolate = new V8\Isolate();
$f1 = function () {};
$f2 = function () {};
$helper->header('Functions before setting as a callback');
debug_zval_dump($f1);
debug_zval_dump($f2);
$fnc = new \V8\FunctionTemplate($isolate, $f1);
$helper->header('Functions after f1 was set as a callback');
debug_zval_dump($f1);
debug_zval_dump($f2);
$fnc->setCallHandler($f2);
$helper->header('Functions after f2 was set as a callback');
debug_zval_dump($f1);
debug_zval_dump($f2);
$fnc = null;
$helper->header('Functions after function template was destroyed');
debug_zval_dump($f1);
debug_zval_dump($f2);
$isolate = null;
//for($i = 0; $i<1000; $i++) {
// $isolate->lowMemoryNotification();
//}
$helper->header('Functions after isolate was destroyed');
debug_zval_dump($f1);
debug_zval_dump($f2);
echo 'We are done for now', PHP_EOL;
?>
--EXPECT--
Functions before setting as a callback:
---------------------------------------
object(Closure)#4 (0) refcount(2){
}
object(Closure)#5 (0) refcount(2){
}
Functions after f1 was set as a callback:
-----------------------------------------
object(Closure)#4 (0) refcount(3){
}
object(Closure)#5 (0) refcount(2){
}
Functions after f2 was set as a callback:
-----------------------------------------
object(Closure)#4 (0) refcount(2){
}
object(Closure)#5 (0) refcount(3){
}
Functions after function template was destroyed:
------------------------------------------------
object(Closure)#4 (0) refcount(2){
}
object(Closure)#5 (0) refcount(3){
}
Functions after isolate was destroyed:
--------------------------------------
object(Closure)#4 (0) refcount(2){
}
object(Closure)#5 (0) refcount(2){
}
We are done for now