-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathstubs.php
75 lines (64 loc) · 1.99 KB
/
stubs.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
<?php
declare(strict_types=1);
namespace ilimit {
/**
* Call a callback while imposing limits on the CPU time and memory that
* the call may consume.
*
* @param callable $callable The invocation to make.
* @param array $arguments The list of arguments.
* @param int $timeout The maximum execution time, in microseconds.
* @param int $maxMemory The maximum amount of memory, in bytes.
* If set to zero, no limit is imposed.
* @param int $checkInterval The interval between memory checks,
* in microseconds. If set to zero or less,
* a default interval of 100 microseconds is used.
*
* @return mixed Returns the return value of the callback.
*
* @throws Error\Runtime If timeout is not positive.
* @throws Error\Runtime If maxMemory is negative.
* @throws Error\System If the system lacks necessary resources to make the call.
* @throws Error\Timeout If the invocation exceeds the allowed time.
* @throws Error\Memory If the invocation exceeds the allowed memory.
*/
function call(
callable $callable,
array $arguments,
int $timeout,
int $maxMemory = 0,
int $checkInterval = 0
) {}
/**
* Thrown when the invocation exceeds the allowed limits.
*/
class Error extends \Exception
{
}
}
namespace ilimit\Error {
use ilimit\Error;
/**
* Thrown when invalid arguments supplied at runtime
*/
class Runtime extends Error {
}
/**
* Thrown when the system lacks necessary resources to make the call.
*/
class System extends Error
{
}
/**
* Thrown when the invocation exceeds the allowed time.
*/
class Timeout extends Error
{
}
/**
* Thrown when the invocation exceeds the allowed memory.
*/
class Memory extends Error
{
}
}