|
| 1 | +<?php |
| 2 | + |
| 3 | +class V8Js |
| 4 | +{ |
| 5 | + /* Constants */ |
| 6 | + const V8_VERSION = ''; |
| 7 | + |
| 8 | + const FLAG_NONE = 1; |
| 9 | + |
| 10 | + const FLAG_FORCE_ARRAY = 2; |
| 11 | + |
| 12 | + const DEBUG_AUTO_BREAK_NEVER = 1; |
| 13 | + |
| 14 | + const DEBUG_AUTO_BREAK_ONCE = 2; |
| 15 | + |
| 16 | + const DEBUG_AUTO_BREAK_ALWAYS = 3; |
| 17 | + |
| 18 | + /* Methods */ |
| 19 | + |
| 20 | + /** |
| 21 | + * Initializes and starts V8 engine and Returns new V8Js object with it's own V8 context. |
| 22 | + * |
| 23 | + * @param string $object_name |
| 24 | + * @param array $variables |
| 25 | + * @param array $extensions |
| 26 | + * @param bool $report_uncaught_exceptions |
| 27 | + */ |
| 28 | + public function __construct($object_name = 'PHP', array $variables = null, array $extensions = null, $report_uncaught_exceptions = true) |
| 29 | + {} |
| 30 | + |
| 31 | + /** |
| 32 | + * Provide a function or method to be used to load required modules. |
| 33 | + * This can be any valid PHP callable. |
| 34 | + * The loader function will receive the normalised module path and should return Javascript code to be executed. |
| 35 | + * |
| 36 | + * @param callable $loader |
| 37 | + */ |
| 38 | + public function setModuleLoader(callable $loader) |
| 39 | + {} |
| 40 | + |
| 41 | + /** |
| 42 | + * Compiles and executes script in object's context with optional identifier string. |
| 43 | + * A time limit (milliseconds) and/or memory limit (bytes) can be provided to restrict execution. These options will throw a V8JsTimeLimitException or V8JsMemoryLimitException. |
| 44 | + * |
| 45 | + * @param string $script |
| 46 | + * @param string $identifier |
| 47 | + * @param int $flags |
| 48 | + * @param int $time_limit in milliseconds |
| 49 | + * @param int $memory_limit in bytes |
| 50 | + * |
| 51 | + * @return mixed |
| 52 | + */ |
| 53 | + public function executeString($script, $identifier = '', $flags = self::FLAG_NONE, $time_limit = 0, $memory_limit = 0) |
| 54 | + {} |
| 55 | + |
| 56 | + /** |
| 57 | + * Compiles a script in object's context with optional identifier string. |
| 58 | + * |
| 59 | + * @param |
| 60 | + * $script |
| 61 | + * @param string $identifier |
| 62 | + * @return resource |
| 63 | + */ |
| 64 | + public function compileString($script, $identifier = '') |
| 65 | + {} |
| 66 | + |
| 67 | + /** |
| 68 | + * Executes a precompiled script in object's context. |
| 69 | + * A time limit (milliseconds) and/or memory limit (bytes) can be provided to restrict execution. These options will throw a V8JsTimeLimitException or V8JsMemoryLimitException. |
| 70 | + * |
| 71 | + * @param resource $script |
| 72 | + * @param int $flags |
| 73 | + * @param int $time_limit |
| 74 | + * @param int $memory_limit |
| 75 | + */ |
| 76 | + public function executeScript($script, $flags = self::FLAG_NONE, $time_limit = 0, $memory_limit = 0) |
| 77 | + {} |
| 78 | + |
| 79 | + /** |
| 80 | + * Set the time limit (in milliseconds) for this V8Js object |
| 81 | + * works similar to the set_time_limit php |
| 82 | + * |
| 83 | + * @param int $limit |
| 84 | + */ |
| 85 | + public function setTimeLimit($limit) |
| 86 | + {} |
| 87 | + |
| 88 | + /** |
| 89 | + * Set the memory limit (in bytes) for this V8Js object |
| 90 | + * |
| 91 | + * @param int $limit |
| 92 | + */ |
| 93 | + public function setMemoryLimit($limit) |
| 94 | + {} |
| 95 | + |
| 96 | + /** |
| 97 | + * Returns uncaught pending exception or null if there is no pending exception. |
| 98 | + * |
| 99 | + * @return V8JsScriptException|null |
| 100 | + */ |
| 101 | + public function getPendingException() |
| 102 | + {} |
| 103 | + |
| 104 | + /** |
| 105 | + * Clears the uncaught pending exception |
| 106 | + */ |
| 107 | + public function clearPendingException() |
| 108 | + {} |
| 109 | + |
| 110 | + /** |
| 111 | + * Starts V8 debug agent for use with Google Chrome Developer Tools (Eclipse Plugin) |
| 112 | + * |
| 113 | + * @param string $agent_name |
| 114 | + * @param int $port |
| 115 | + * @param int $auto_break |
| 116 | + * |
| 117 | + * @return bool |
| 118 | + */ |
| 119 | + public function startDebugAgent($agent_name = 'V8Js', $port = 9222, $auto_break = self::DEBUG_AUTO_BREAK_NEVER) |
| 120 | + {} |
| 121 | + |
| 122 | + /** |
| 123 | + * Static methods * |
| 124 | + */ |
| 125 | + |
| 126 | + /** |
| 127 | + * Registers persistent context independent global Javascript extension. |
| 128 | + * NOTE! These extensions exist until PHP is shutdown and they need to be registered before V8 is initialized. |
| 129 | + * For best performance V8 is initialized only once per process thus this call has to be done before any V8Js objects are created! |
| 130 | + * |
| 131 | + * @param string $extension_name |
| 132 | + * @param string $code |
| 133 | + * @param array $dependencies |
| 134 | + * @param bool $auto_enable |
| 135 | + * |
| 136 | + * @return bool |
| 137 | + */ |
| 138 | + public static function registerExtension($extension_name, $code, array $dependencies, $auto_enable = false) |
| 139 | + {} |
| 140 | + |
| 141 | + /** |
| 142 | + * Returns extensions successfully registered with V8Js::registerExtension(). |
| 143 | + * |
| 144 | + * @return array|string[] |
| 145 | + */ |
| 146 | + public static function getExtensions() |
| 147 | + {} |
| 148 | +} |
0 commit comments