mintware-de / v8world
A wrapper for the ext-v8js php extension.
v1.0.0
2022-11-27 16:25 UTC
Requires
- php: ^8.1
- ext-v8js: ^2.1.2
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.13
- phpstan/phpstan: ^1.9
- phpunit/phpunit: ^9.5
README
A wrapper for the v8js
extension.
Why
Without V8 World
With V8 World
*: The real instance of objects is still an V8Object but the type hints will help you to reduce possible bugs.
How?
- The wrapper takes an instance of
\V8Js
+ an$initialState
1 class. - The phpdoc tells your IDE that the wrapper is an instance of
\V8Js&InitialState
. - Your IDE provides autocomplete features and your static analyzer should detect common typing problems.
Example
See _docs/example.md.
Important notes
This package is just a "band-aid for a bullet hole".
- Since
V8World::modify()
will not create a new instance of theV8Js
object, the oldV8World
is also affected- The IDE will not provide autocompletion for the old
V8World
object but for the new one.
- The IDE will not provide autocompletion for the old
- Keep in mind that changing the stubs will not affect the underlying JS code - not even vice versa.
- Don't trust the stubs if you're working with objects and functions.
- If a method returns an object or a property holds an instance of an object, V8Js always return an
\V8Object
- If a method returns an function or a property holds an instance of an function, V8Js always return an
\V8Function
- If a method returns an object or a property holds an instance of an object, V8Js always return an