0
0
mirror of https://github.com/phpv8/v8js.git synced 2024-12-23 08:21:53 +00:00

Change the invalid php stub with valid php code that can be used for type hinting

This commit is contained in:
Christiaan 2015-01-01 21:43:26 +01:00
parent e52e6a3617
commit b6a923c949

210
README.md
View File

@ -81,95 +81,171 @@ PHP API
======= =======
```php ```php
class V8Js <?php
{ class V8Js
/* Constants */ {
/* Constants */
const string V8_VERSION; const V8_VERSION = '';
const int FLAG_NONE; const FLAG_NONE = 1;
const int FLAG_FORCE_ARRAY; const FLAG_FORCE_ARRAY = 2;
const int DEBUG_AUTO_BREAK_NEVER; const DEBUG_AUTO_BREAK_NEVER = 1;
const int DEBUG_AUTO_BREAK_ONCE; const DEBUG_AUTO_BREAK_ONCE = 2;
const int DEBUG_AUTO_BREAK_ALWAYS; const DEBUG_AUTO_BREAK_ALWAYS = 3;
/* Methods */ /* Methods */
// Initializes and starts V8 engine and Returns new V8Js object with it's own V8 context. /**
public __construct ( [ string $object_name = "PHP" [, array $variables = NULL [, array $extensions = NULL [, bool $report_uncaught_exceptions = TRUE ] ] ] ) * Initializes and starts V8 engine and Returns new V8Js object with it's own V8 context.
* @param string $object_name
* @param array $variables
* @param array $extensions
* @param bool $report_uncaught_exceptions
*/
public function __construct($object_name = "PHP", array $variables = NULL, array $extensions = NULL, $report_uncaught_exceptions = TRUE)
{}
// Provide a function or method to be used to load required modules. This can be any valid PHP callable. /**
// The loader function will receive the normalised module path and should return Javascript code to be executed. * Provide a function or method to be used to load required modules. This can be any valid PHP callable.
public setModuleLoader ( callable $loader ) * The loader function will receive the normalised module path and should return Javascript code to be executed.
* @param callable $loader
*/
public function setModuleLoader(callable $loader)
{}
// Compiles and executes script in object's context with optional identifier string. /**
// A time limit (milliseconds) and/or memory limit (bytes) can be provided to restrict execution. These options will throw a V8JsTimeLimitException or V8JsMemoryLimitException. * Compiles and executes script in object's context with optional identifier string.
public mixed V8Js::executeString( string $script [, string $identifier [, int $flags = V8Js::FLAG_NONE [, int $time_limit = 0 [, int $memory_limit = 0]]]]) * A time limit (milliseconds) and/or memory limit (bytes) can be provided to restrict execution. These options will throw a V8JsTimeLimitException or V8JsMemoryLimitException.
* @param string $script
* @param string $identifier
* @param int $flags
* @param int $time_limit in milliseconds
* @param int $memory_limit in bytes
* @return mixed
*/
public function executeString($script, $identifier = '', $flags = V8Js::FLAG_NONE, $time_limit = 0, $memory_limit = 0)
{}
// Set the time limit (in milliseconds) for this V8Js object works similar to the set_time_limit php function /**
public setTimeLimit( int $limit ) * Compiles a script in object's context with optional identifier string.
* @param $script
* @param string $identifier
* @return resource
*/
public function compileString($script, $identifier = '')
{}
// Set the memory limit (in bytes) for this V8Js object /**
public setMemoryLimit( int $limit ) * Executes a precompiled script in object's context.
* A time limit (milliseconds) and/or memory limit (bytes) can be provided to restrict execution. These options will throw a V8JsTimeLimitException or V8JsMemoryLimitException.
* @param resource $script
* @param int $flags
* @param int $time_limit
* @param int $memory_limit
*/
public function executeScript($script, $flags = V8Js::FLAG_NONE, $time_limit = 0 , $memory_limit = 0)
{}
// Compiles a script in object's context with optional identifier string. /**
public mixed V8Js::compileString( string $script [, string $identifier ]) * Set the time limit (in milliseconds) for this V8Js object
* works similar to the set_time_limit php
* @param int $limit
*/
public function setTimeLimit($limit)
{}
// Executes a precompiled script in object's context. /**
// A time limit (milliseconds) and/or memory limit (bytes) can be provided to restrict execution. These options will throw a V8JsTimeLimitException or V8JsMemoryLimitException. * Set the memory limit (in bytes) for this V8Js object
public mixed V8Js::executeScript( resource $script [, int $flags = V8Js::FLAG_NONE [, int $time_limit = 0 [, int $memory_limit = 0]]]) * @param int $limit
*/
public function setMemoryLimit($limit)
{}
// Returns uncaught pending exception or null if there is no pending exception. /**
public V8JsScriptException V8Js::getPendingException( ) * Returns uncaught pending exception or null if there is no pending exception.
* @return V8JsScriptException|null
*/
public function getPendingException()
{}
// Clears the uncaught pending exception /**
public clearPendingException( ) * Clears the uncaught pending exception
*/
public function clearPendingException()
{}
// Starts V8 debug agent for use with Google Chrome Developer Tools (Eclipse Plugin) /**
public bool startDebugAgent( [ string $agent_name = "V8Js" [, $port = 9222 [, $auto_break = V8Js::DEBUG_AUTO_BREAK_NEVER ] ] ] ) * Starts V8 debug agent for use with Google Chrome Developer Tools (Eclipse Plugin)
* @param string $agent_name
* @param int $port
* @param int $auto_break
* @return bool
*/
public function startDebugAgent($agent_name = "V8Js", $port = 9222, $auto_break = V8Js::DEBUG_AUTO_BREAK_NEVER)
{}
/** Static methods **/ /** Static methods **/
// Registers persistent context independent global Javascript extension. /**
// NOTE! These extensions exist until PHP is shutdown and they need to be registered before V8 is initialized. * Registers persistent context independent global Javascript extension.
// For best performance V8 is initialized only once per process thus this call has to be done before any V8Js objects are created! * NOTE! These extensions exist until PHP is shutdown and they need to be registered before V8 is initialized.
public static bool V8Js::registerExtension( string $extension_name, string $code [, array $dependenciess [, bool $auto_enable = FALSE ] ] ) * For best performance V8 is initialized only once per process thus this call has to be done before any V8Js objects are created!
* @param string $extension_name
* @param string $code
* @param array $dependencies
* @param bool $auto_enable
* @return bool
*/
public static function registerExtension($extension_name, $code, array $dependencies, $auto_enable = FALSE)
{}
// Returns extensions successfully registered with V8Js::registerExtension(). /**
public static array V8Js::getExtensions( ) * Returns extensions successfully registered with V8Js::registerExtension().
} * @return array|string[]
*/
public static function getExtensions()
{}
}
class V8JsException extends RuntimeException final class V8JsScriptException extends Exception
{ {
} /**
* @return string
*/
final public function getJsFileName( ) {}
final class V8JsScriptException extends V8JsException /**
{ * @return int
/* Properties */ */
protected string JsFileName = NULL; final public function getJsLineNumber( ) {}
protected int JsLineNumber = NULL; /**
protected int JsStartColumn = NULL; * @return int
protected int JsEndColumn = NULL; */
protected string JsSourceLine = NULL; final public function getJsStartColumn( ) {}
protected string JsTrace = NULL; /**
* @return int
*/
final public function getJsEndColumn( ) {}
/* Methods */ /**
final public string getJsFileName( ) * @return string
final public int getJsLineNumber( ) */
final public int getJsStartColumn( ) final public function getJsSourceLine( ) {}
final public int getJsEndColumn( ) /**
final public string getJsSourceLine( ) * @return string
final public string getJsTrace( ) */
} final public function getJsTrace( ) {}
}
final class V8JsTimeLimitException extends V8JsException final class V8JsTimeLimitException extends Exception
{ {
} }
final class V8JsMemoryLimitException extends V8JsException final class V8JsMemoryLimitException extends Exception
{ {
} }
``` ```
Javascript API Javascript API