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 pathContext.php
154 lines (139 loc) · 4.43 KB
/
Context.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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
<?php declare(strict_types=1);
/**
* This file is part of the pinepain/php-v8 PHP extension.
*
* Copyright (c) 2015-2017 Bogdan Padalko <pinepain@gmail.com>
*
* Licensed under the MIT license: http://opensource.org/licenses/MIT
*
* For the full copyright and license information, please view the
* LICENSE file that was distributed with this source or visit
* http://opensource.org/licenses/MIT
*/
namespace V8;
/**
* A sandboxed execution context with its own set of built-in objects
* and functions.
*/
class Context
{
/**
* @var Isolate
*/
private $isolate;
/**
* Creates a new context and returns a handle to the newly allocated
* context.
*
* \param isolate The isolate in which to create the context.
*
* \param global_template An optional object template from which the
* global object for the newly created context will be created.
*
* \param global_object An optional global object to be reused for
* the newly created context. This global object must have been
* created by a previous call to Context::New with the same global
* template. The state of the global object will be completely reset
* and only object identify will remain.
*
* @param Isolate $isolate
* @param ObjectTemplate|null $global_template
* @param ObjectValue|null $global_object
*
* @internal param array|null $extensions Currently unused as there are not extensions support
*/
public function __construct(Isolate $isolate, ObjectTemplate $global_template = null, ObjectValue $global_object = null)
{
}
/**
* @return Isolate
*/
public function getIsolate(): Isolate
{
return $this->isolate;
}
/**
* Returns the global proxy object.
*
* Global proxy object is a thin wrapper whose prototype points to actual
* context's global object with the properties like Object, etc. This is done
* that way for security reasons (for more details see
* https://wiki.mozilla.org/Gecko:SplitWindow).
*
* Please note that changes to global proxy object prototype most probably
* would break VM---v8 expects only global object as a prototype of global
* proxy object.
*
* @return ObjectValue
*/
public function globalObject(): ObjectValue
{
}
/**
* Detaches the global object from its context before
* the global object can be reused to create a new context.
*/
public function detachGlobal()
{
}
/**
* Sets the security token for the context. To access an object in
* another context, the security tokens must match.
*
* @param Value $token
*/
public function setSecurityToken(Value $token)
{
}
/**
* Restores the security token to the default value.
*/
public function useDefaultSecurityToken()
{
}
/**
* Returns the security token of this context.
*
* @return Value|PrimitiveValue|ObjectValue
*/
public function getSecurityToken(): Value
{
}
/**
* Control whether code generation from strings is allowed. Calling
* this method with false will disable 'eval' and the 'Function'
* constructor for code running in this context. If 'eval' or the
* 'Function' constructor are used an exception will be thrown.
*
* If code generation from strings is not allowed the
* V8::AllowCodeGenerationFromStrings callback will be invoked if
* set before blocking the call to 'eval' or the 'Function'
* constructor. If that callback returns true, the call will be
* allowed, otherwise an exception will be thrown. If no callback is
* set an exception will be thrown.
*
* @param bool $allow
*/
public function allowCodeGenerationFromStrings(bool $allow)
{
}
/**
* Returns true if code generation from strings is allowed for the context.
* For more details see AllowCodeGenerationFromStrings(bool) documentation.
*
* @return bool
*/
public function isCodeGenerationFromStringsAllowed(): bool
{
}
/**
* Sets the error description for the exception that is thrown when
* code generation from strings is not allowed and 'eval' or the 'Function'
* constructor are called.
*
* @param StringValue $message
*/
public function setErrorMessageForCodeGenerationFromStrings(StringValue $message)
{
}
}