0
0
mirror of https://github.com/phpv8/v8js.git synced 2024-11-08 12:38:41 +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

214
README.md
View File

@ -81,95 +81,171 @@ PHP API
=======
```php
class V8Js
{
/* Constants */
<?php
class V8Js
{
/* Constants */
const string V8_VERSION;
const V8_VERSION = '';
const int FLAG_NONE;
const int FLAG_FORCE_ARRAY;
const FLAG_NONE = 1;
const FLAG_FORCE_ARRAY = 2;
const int DEBUG_AUTO_BREAK_NEVER;
const int DEBUG_AUTO_BREAK_ONCE;
const int DEBUG_AUTO_BREAK_ALWAYS;
/* Methods */
const DEBUG_AUTO_BREAK_NEVER = 1;
const DEBUG_AUTO_BREAK_ONCE = 2;
const DEBUG_AUTO_BREAK_ALWAYS = 3;
// 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 ] ] ] )
/* Methods */
// 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.
public setModuleLoader ( callable $loader )
/**
* 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)
{}
// 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.
public mixed V8Js::executeString( string $script [, string $identifier [, int $flags = V8Js::FLAG_NONE [, int $time_limit = 0 [, int $memory_limit = 0]]]])
/**
* 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.
* @param callable $loader
*/
public function setModuleLoader(callable $loader)
{}
// Set the time limit (in milliseconds) for this V8Js object works similar to the set_time_limit php function
public setTimeLimit( int $limit )
/**
* 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.
* @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 memory limit (in bytes) for this V8Js object
public setMemoryLimit( 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 = '')
{}
// Compiles a script in object's context with optional identifier string.
public mixed V8Js::compileString( string $script [, string $identifier ])
/**
* 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)
{}
// 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.
public mixed V8Js::executeScript( resource $script [, int $flags = V8Js::FLAG_NONE [, int $time_limit = 0 [, int $memory_limit = 0]]])
/**
* 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)
{}
// Returns uncaught pending exception or null if there is no pending exception.
public V8JsScriptException V8Js::getPendingException( )
/**
* Set the memory limit (in bytes) for this V8Js object
* @param int $limit
*/
public function setMemoryLimit($limit)
{}
// Clears the uncaught pending exception
public clearPendingException( )
/**
* Returns uncaught pending exception or null if there is no pending exception.
* @return V8JsScriptException|null
*/
public function getPendingException()
{}
// 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 ] ] ] )
/**
* Clears the uncaught pending exception
*/
public function clearPendingException()
{}
/** Static methods **/
/**
* 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)
{}
// 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.
// For best performance V8 is initialized only once per process thus this call has to be done before any V8Js objects are created!
public static bool V8Js::registerExtension( string $extension_name, string $code [, array $dependenciess [, bool $auto_enable = FALSE ] ] )
/** Static methods **/
// Returns extensions successfully registered with V8Js::registerExtension().
public static array V8Js::getExtensions( )
}
/**
* 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.
* 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)
{}
class V8JsException extends RuntimeException
{
}
/**
* Returns extensions successfully registered with V8Js::registerExtension().
* @return array|string[]
*/
public static function getExtensions()
{}
}
final class V8JsScriptException extends V8JsException
{
/* Properties */
protected string JsFileName = NULL;
protected int JsLineNumber = NULL;
protected int JsStartColumn = NULL;
protected int JsEndColumn = NULL;
protected string JsSourceLine = NULL;
protected string JsTrace = NULL;
/* Methods */
final public string getJsFileName( )
final public int getJsLineNumber( )
final public int getJsStartColumn( )
final public int getJsEndColumn( )
final public string getJsSourceLine( )
final public string getJsTrace( )
}
final class V8JsScriptException extends Exception
{
/**
* @return string
*/
final public function getJsFileName( ) {}
final class V8JsTimeLimitException extends V8JsException
{
}
/**
* @return int
*/
final public function getJsLineNumber( ) {}
/**
* @return int
*/
final public function getJsStartColumn( ) {}
/**
* @return int
*/
final public function getJsEndColumn( ) {}
final class V8JsMemoryLimitException extends V8JsException
{
}
/**
* @return string
*/
final public function getJsSourceLine( ) {}
/**
* @return string
*/
final public function getJsTrace( ) {}
}
final class V8JsTimeLimitException extends Exception
{
}
final class V8JsMemoryLimitException extends Exception
{
}
```
Javascript API