diff --git a/config.m4 b/config.m4 index 63dd6bf..25d2b41 100644 --- a/config.m4 +++ b/config.m4 @@ -175,6 +175,7 @@ if test "$PHP_V8" != "no"; then src/php_v8_data.cc \ src/php_v8_value.cc \ src/php_v8_primitive.cc \ + src/php_v8_undefined.cc \ src/php_v8_null.cc \ src/php_v8_boolean.cc \ src/php_v8_name.cc \ diff --git a/php_v8.h b/php_v8.h index 533320b..5467a26 100644 --- a/php_v8.h +++ b/php_v8.h @@ -71,6 +71,10 @@ ZEND_END_MODULE_GLOBALS(v8) ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(name, return_reference, required_num_args, type, NULL, allow_null) #endif +#if PHP_VERSION_ID < 70100 + #define zend_get_executed_scope() EG(scope) +#endif + /* Always refer to the globals in your function as PHP_V8_G(variable). You are encouraged to rename these macros something shorter, see diff --git a/src/php_v8_function.cc b/src/php_v8_function.cc index 51f6fc9..9c43d0e 100644 --- a/src/php_v8_function.cc +++ b/src/php_v8_function.cc @@ -47,16 +47,12 @@ bool php_v8_function_unpack_args(zval *arguments_zv, int arg_position, v8::Isola char *exception_message; - #if PHP_VERSION_ID >= 70100 zend_string *ce_name = zend_get_executed_scope()->name; - #else - zend_string *ce_name = EG(scope)->name; - #endif ZEND_HASH_FOREACH_VAL(myht, pzval) { if (Z_TYPE_P(pzval) != IS_OBJECT) { zend_throw_error(zend_ce_type_error, - "Argument %d passed to %s::%s() should be array of \\V8\\Value objects, %s given at %d offset", + "Argument %d passed to %s::%s() must be an array of \\V8\\Value objects, %s given at %d offset", arg_position, ZSTR_VAL(ce_name), get_active_function_name(), zend_zval_type_name(pzval), i); @@ -66,7 +62,7 @@ bool php_v8_function_unpack_args(zval *arguments_zv, int arg_position, v8::Isola if (!instanceof_function(Z_OBJCE_P(pzval), php_v8_value_class_entry)) { zend_throw_error(zend_ce_type_error, - "Argument %d passed to %s::%s() should be array of \\V8\\Value objects, instance of %s given at %d offset", + "Argument %d passed to %s::%s() must be an array of \\V8\\Value objects, instance of %s given at %d offset", arg_position, ZSTR_VAL(ce_name), get_active_function_name(), ZSTR_VAL(Z_OBJCE_P(pzval)->name), i); @@ -136,16 +132,12 @@ bool php_v8_function_unpack_string_args(zval* arguments_zv, int arg_position, v8 char *exception_message; - #if PHP_VERSION_ID >= 70100 - zend_string *ce_name = zend_get_executed_scope()->name; - #else - zend_string *ce_name = EG(scope)->name; - #endif + zend_string *ce_name = zend_get_executed_scope()->name; ZEND_HASH_FOREACH_VAL(myht, pzval) { if (Z_TYPE_P(pzval) != IS_OBJECT) { zend_throw_error(zend_ce_type_error, - "Argument %d passed to %s::%s() should be array of \\V8\\StringValue objects, %s given at %d offset", + "Argument %d passed to %s::%s() must be an array of \\V8\\StringValue objects, %s given at %d offset", arg_position, ZSTR_VAL(ce_name), get_active_function_name(), zend_zval_type_name(pzval), i); @@ -155,7 +147,7 @@ bool php_v8_function_unpack_string_args(zval* arguments_zv, int arg_position, v8 if (!instanceof_function(Z_OBJCE_P(pzval), php_v8_string_class_entry)) { zend_throw_error(zend_ce_type_error, - "Argument %d passed to %s::%s() should be array of \\V8\\StringValue, instance of %s given at %d offset", + "Argument %d passed to %s::%s() must be an array of \\V8\\StringValue, instance of %s given at %d offset", arg_position, ZSTR_VAL(ce_name), get_active_function_name(), ZSTR_VAL(Z_OBJCE_P(pzval)->name), i); @@ -225,16 +217,12 @@ bool php_v8_function_unpack_object_args(zval* arguments_zv, int arg_position, v8 char *exception_message; - #if PHP_VERSION_ID >= 70100 zend_string *ce_name = zend_get_executed_scope()->name; - #else - zend_string *ce_name = EG(scope)->name; - #endif ZEND_HASH_FOREACH_VAL(myht, pzval) { if (Z_TYPE_P(pzval) != IS_OBJECT) { zend_throw_error(zend_ce_type_error, - "Argument %d passed to %s::%s() should be array of \\V8\\ObjectValue objects, %s given at %d offset", + "Argument %d passed to %s::%s() must be an array of \\V8\\ObjectValue objects, %s given at %d offset", arg_position, ZSTR_VAL(ce_name), get_active_function_name(), zend_zval_type_name(pzval), i); @@ -244,7 +232,7 @@ bool php_v8_function_unpack_object_args(zval* arguments_zv, int arg_position, v8 if (!instanceof_function(Z_OBJCE_P(pzval), php_v8_object_class_entry)) { zend_throw_error(zend_ce_type_error, - "Argument %d passed to %s::%s() should be array of \\V8\\ObjectValue, instance of %s given at %d offset", + "Argument %d passed to %s::%s() must be an array of \\V8\\ObjectValue, instance of %s given at %d offset", arg_position, ZSTR_VAL(ce_name), get_active_function_name(), ZSTR_VAL(Z_OBJCE_P(pzval)->name), i); diff --git a/src/php_v8_name.cc b/src/php_v8_name.cc index d561e7c..d74626e 100644 --- a/src/php_v8_name.cc +++ b/src/php_v8_name.cc @@ -58,6 +58,7 @@ PHP_MINIT_FUNCTION(php_v8_name) zend_class_entry ce; INIT_NS_CLASS_ENTRY(ce, PHP_V8_NS, "NameValue", php_v8_name_methods); this_ce = zend_register_internal_class_ex(&ce, php_v8_primitive_class_entry); + this_ce->ce_flags |= ZEND_ACC_EXPLICIT_ABSTRACT_CLASS; return SUCCESS; } diff --git a/src/php_v8_primitive.cc b/src/php_v8_primitive.cc index 4463c93..30601ad 100644 --- a/src/php_v8_primitive.cc +++ b/src/php_v8_primitive.cc @@ -32,6 +32,7 @@ PHP_MINIT_FUNCTION(php_v8_primitive) zend_class_entry ce; INIT_NS_CLASS_ENTRY(ce, PHP_V8_NS, "PrimitiveValue", php_v8_primitive_methods); this_ce = zend_register_internal_class_ex(&ce, php_v8_value_class_entry); + this_ce->ce_flags |= ZEND_ACC_EXPLICIT_ABSTRACT_CLASS; return SUCCESS; } diff --git a/src/php_v8_template.cc b/src/php_v8_template.cc index 219c344..f3ce352 100644 --- a/src/php_v8_template.cc +++ b/src/php_v8_template.cc @@ -140,7 +140,19 @@ void php_v8_template_Set(v8::Isolate *isolate, v8::Local local_template, N* p PHP_V8_DATA_ISOLATES_CHECK(php_v8_template, php_v8_value_to_set); - local_template->Set(local_name, php_v8_value_get_local(php_v8_value_to_set), static_cast(attributes)); + v8::Local local_value = php_v8_value_get_local(php_v8_value_to_set); + + if (local_value->IsObject()) { + int arg_position = 3; + zend_string *ce_name = zend_get_executed_scope()->name; + + zend_throw_error(zend_ce_type_error, + "Argument %d passed to %s::%s() must be an instance of \\V8\\PrimitiveValue or \\V8\\Template, instance of %s given", + arg_position, ZSTR_VAL(ce_name), get_active_function_name(), ZSTR_VAL(Z_OBJCE_P(php_v8_value_zv)->name)); + return; + } + + local_template->Set(local_name, local_value, static_cast(attributes)); } else if (instanceof_function(Z_OBJCE_P(php_v8_value_zv), php_v8_object_template_class_entry)) { // set object template PHP_V8_FETCH_OBJECT_TEMPLATE_WITH_CHECK(php_v8_value_zv, php_v8_object_template_to_set); diff --git a/src/php_v8_undefined.cc b/src/php_v8_undefined.cc new file mode 100644 index 0000000..1a8b1ae --- /dev/null +++ b/src/php_v8_undefined.cc @@ -0,0 +1,56 @@ +/* + * This file is part of the pinepain/php-v8 PHP extension. + * + * Copyright (c) 2015-2017 Bogdan Padalko + * + * Licensed under the MIT license: http://opensource.org/licenses/MIT + * + * For the full copyright and license information, please view the + * LICENSE file that was distributed with this source or visit + * http://opensource.org/licenses/MIT + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include "php_v8_undefined.h" +#include "php_v8_primitive.h" +#include "php_v8_value.h" +#include "php_v8.h" + +zend_class_entry *php_v8_undefined_class_entry; +#define this_ce php_v8_undefined_class_entry + + +static PHP_METHOD(V8Undefined, __construct) { + zval *php_v8_isolate_zv; + + if (zend_parse_parameters(ZEND_NUM_ARGS(), "o", &php_v8_isolate_zv) == FAILURE) { + return; + } + + PHP_V8_VALUE_CONSTRUCT(getThis(), php_v8_isolate_zv, php_v8_isolate, php_v8_value); + + php_v8_value->persistent->Reset(isolate, v8::Undefined(isolate)); +} + + +ZEND_BEGIN_ARG_INFO_EX(arginfo_v8_undefined___construct, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 1) + ZEND_ARG_OBJ_INFO(0, isolate, V8\\Isolate, 0) +ZEND_END_ARG_INFO() + + +static const zend_function_entry php_v8_undefined_methods[] = { + PHP_ME(V8Undefined, __construct, arginfo_v8_undefined___construct, ZEND_ACC_PUBLIC | ZEND_ACC_CTOR) + PHP_FE_END +}; + + +PHP_MINIT_FUNCTION(php_v8_undefined) { + zend_class_entry ce; + INIT_NS_CLASS_ENTRY(ce, PHP_V8_NS, "UndefinedValue", php_v8_undefined_methods); + this_ce = zend_register_internal_class_ex(&ce, php_v8_primitive_class_entry); + + return SUCCESS; +} diff --git a/src/php_v8_undefined.h b/src/php_v8_undefined.h new file mode 100644 index 0000000..f8469e5 --- /dev/null +++ b/src/php_v8_undefined.h @@ -0,0 +1,29 @@ +/* + * This file is part of the pinepain/php-v8 PHP extension. + * + * Copyright (c) 2015-2017 Bogdan Padalko + * + * Licensed under the MIT license: http://opensource.org/licenses/MIT + * + * For the full copyright and license information, please view the + * LICENSE file that was distributed with this source or visit + * http://opensource.org/licenses/MIT + */ + +#ifndef PHP_V8_UNDEFINED_H +#define PHP_V8_UNDEFINED_H + +extern "C" { +#include "php.h" + +#ifdef ZTS +#include "TSRM.h" +#endif +} + +extern zend_class_entry* php_v8_undefined_class_entry; + + +PHP_MINIT_FUNCTION(php_v8_undefined); + +#endif //PHP_V8_UNDEFINED_H diff --git a/src/php_v8_value.cc b/src/php_v8_value.cc index 7c63312..0f99988 100644 --- a/src/php_v8_value.cc +++ b/src/php_v8_value.cc @@ -38,6 +38,7 @@ #include "php_v8_uint32.h" #include "php_v8_integer.h" #include "php_v8_number.h" +#include "php_v8_undefined.h" /* end of type listing */ #include "php_v8_data.h" @@ -231,7 +232,7 @@ zend_class_entry *php_v8_get_class_entry_from_value(v8::Local value) // working with scalars if (value->IsUndefined()) { - return php_v8_value_class_entry; + return php_v8_undefined_class_entry; } if (value->IsNull()) { @@ -313,17 +314,15 @@ php_v8_value_t *php_v8_get_or_create_value(zval *return_value, v8::Localpersistent->Reset(isolate, v8::Undefined(isolate)); -} +//static PHP_METHOD (V8Value, __construct) { +// zval *php_v8_isolate_zv; +// +// if (zend_parse_parameters(ZEND_NUM_ARGS(), "o", &php_v8_isolate_zv) == FAILURE) { +// return; +// } +// +// PHP_V8_THROW_EXCEPTION("V8\\Value::__construct() should not be called. Use specific values instead.") +//} static PHP_METHOD(V8Value, GetIsolate) { zval rv; @@ -1062,7 +1061,8 @@ ZEND_END_ARG_INFO() static const zend_function_entry php_v8_value_methods[] = { - PHP_ME(V8Value, __construct, arginfo_v8_value___construct, ZEND_ACC_PUBLIC | ZEND_ACC_CTOR) +// PHP_ME(V8Value, __construct, arginfo_v8_value___construct, ZEND_ACC_PRIVATE | ZEND_ACC_CTOR) + PHP_ME(V8Value, GetIsolate, arginfo_v8_value_GetIsolate, ZEND_ACC_PUBLIC) PHP_ME(V8Value, IsUndefined, arginfo_v8_value_IsUndefined, ZEND_ACC_PUBLIC) @@ -1146,6 +1146,7 @@ PHP_MINIT_FUNCTION (php_v8_value) { INIT_NS_CLASS_ENTRY(ce, PHP_V8_NS, "Value", php_v8_value_methods); this_ce = zend_register_internal_class_ex(&ce, php_v8_data_class_entry); this_ce->create_object = php_v8_value_ctor; + this_ce->ce_flags |= ZEND_ACC_EXPLICIT_ABSTRACT_CLASS; zend_declare_property_null(this_ce, ZEND_STRL("isolate"), ZEND_ACC_PRIVATE); diff --git a/stubs/src/ArrayObject.php b/stubs/src/ArrayObject.php index e83e297..7a55de6 100644 --- a/stubs/src/ArrayObject.php +++ b/stubs/src/ArrayObject.php @@ -30,7 +30,6 @@ class ArrayObject extends ObjectValue */ public function __construct(Context $context, int $length = 0) { - parent::__construct($context); } /** diff --git a/stubs/src/BooleanObject.php b/stubs/src/BooleanObject.php index 4b87dd7..0dc135c 100644 --- a/stubs/src/BooleanObject.php +++ b/stubs/src/BooleanObject.php @@ -27,7 +27,6 @@ class BooleanObject extends ObjectValue */ public function __construct(Context $context, bool $value) { - parent::__construct($context); } /** diff --git a/stubs/src/BooleanValue.php b/stubs/src/BooleanValue.php index 78311a4..7d54fd7 100644 --- a/stubs/src/BooleanValue.php +++ b/stubs/src/BooleanValue.php @@ -27,7 +27,6 @@ class BooleanValue extends PrimitiveValue */ public function __construct(Isolate $isolate, bool $value) { - parent::__construct($isolate); } /** diff --git a/stubs/src/Exception.php b/stubs/src/Exception.php index bcb6cb2..2168125 100644 --- a/stubs/src/Exception.php +++ b/stubs/src/Exception.php @@ -66,7 +66,7 @@ public static function TypeError(Context $context, StringValue $message): Value * @param Context $context * @param \V8\StringValue $message * - * @return Value + * @return Value | ObjectValue */ public static function Error(Context $context, StringValue $message): Value { diff --git a/stubs/src/NameValue.php b/stubs/src/NameValue.php index 10f5ac3..00024d7 100644 --- a/stubs/src/NameValue.php +++ b/stubs/src/NameValue.php @@ -19,7 +19,7 @@ /** * A superclass for symbols and strings. */ -class NameValue extends PrimitiveValue +abstract class NameValue extends PrimitiveValue { /** * Returns the identity hash for this object. The current implementation diff --git a/stubs/src/NullValue.php b/stubs/src/NullValue.php index 02b84d5..5ce332d 100644 --- a/stubs/src/NullValue.php +++ b/stubs/src/NullValue.php @@ -16,8 +16,12 @@ namespace V8; -class NullValue extends Value +class NullValue extends PrimitiveValue { + public function __construct(Isolate $isolate) + { + } + /** * @return null */ diff --git a/stubs/src/NumberValue.php b/stubs/src/NumberValue.php index 781cc39..82a187e 100644 --- a/stubs/src/NumberValue.php +++ b/stubs/src/NumberValue.php @@ -26,7 +26,6 @@ class NumberValue extends PrimitiveValue */ public function __construct(Isolate $isolate, float $value) { - parent::__construct($isolate); } /** diff --git a/stubs/src/PrimitiveValue.php b/stubs/src/PrimitiveValue.php index ff41854..d13b3fb 100644 --- a/stubs/src/PrimitiveValue.php +++ b/stubs/src/PrimitiveValue.php @@ -19,6 +19,6 @@ /** * The superclass of primitive values. See ECMA-262 4.3.2. */ -class PrimitiveValue extends Value +abstract class PrimitiveValue extends Value { } diff --git a/stubs/src/StringValue.php b/stubs/src/StringValue.php index b98b86a..da067c3 100644 --- a/stubs/src/StringValue.php +++ b/stubs/src/StringValue.php @@ -29,7 +29,6 @@ class StringValue extends NameValue */ public function __construct(Isolate $isolate, $data = '') { - parent::__construct($isolate); } /** diff --git a/stubs/src/SymbolValue.php b/stubs/src/SymbolValue.php index adc9e3a..3951e71 100644 --- a/stubs/src/SymbolValue.php +++ b/stubs/src/SymbolValue.php @@ -31,7 +31,6 @@ class SymbolValue extends NameValue */ public function __construct(Isolate $isolate, StringValue $name = null) { - parent::__construct($isolate); } /** diff --git a/stubs/src/Template.php b/stubs/src/Template.php index 9704add..f486231 100644 --- a/stubs/src/Template.php +++ b/stubs/src/Template.php @@ -42,11 +42,13 @@ public function GetIsolate(): Isolate /** * Adds a property to each instance created by this template. * - * @param NameValue $name - * @param \V8\Data $value - * @param int $attributes One of \v8\PropertyAttribute constants + * @param NameValue $name + * @param PrimitiveValue|Template $value + * @param int $attributes One of \v8\PropertyAttribute constants + * + * @return void */ - public function Set(NameValue $name, Data $value, int $attributes = PropertyAttribute::None) + public function Set(NameValue $name, /*Data*/ $value, int $attributes = PropertyAttribute::None) { } diff --git a/stubs/src/UndefinedValue.php b/stubs/src/UndefinedValue.php new file mode 100644 index 0000000..2f514fa --- /dev/null +++ b/stubs/src/UndefinedValue.php @@ -0,0 +1,26 @@ + + * + * Licensed under the MIT license: http://opensource.org/licenses/MIT + * + * For the full copyright and license information, please view the + * LICENSE file that was distributed with this source or visit + * http://opensource.org/licenses/MIT + */ + + +namespace V8; + +/** + * A primitive undefined value (ECMA-262, 4.3.10). Sole value is the undefined value. + */ +class UndefinedValue extends PrimitiveValue +{ + public function __construct(Isolate $isolate) + { + } +} diff --git a/stubs/src/Value.php b/stubs/src/Value.php index 79abd76..c974bf0 100644 --- a/stubs/src/Value.php +++ b/stubs/src/Value.php @@ -19,27 +19,13 @@ /** * The superclass of all JavaScript values and objects. */ -class Value extends Data +abstract class Value extends Data { - /** - * @var \V8\Isolate - */ - private $isolate; - - /** - * @param Isolate $isolate - */ - public function __construct(\V8\Isolate $isolate) - { - $this->isolate = $isolate; - } - /** * @return \V8\Isolate */ - public function GetIsolate() + public function GetIsolate(): Isolate { - return $this->isolate; } /** diff --git a/tests/.tracking_dtors.php b/tests/.tracking_dtors.php index 82afe6f..de00bc7 100644 --- a/tests/.tracking_dtors.php +++ b/tests/.tracking_dtors.php @@ -58,6 +58,6 @@ class FunctionObject extends \V8\FunctionObject { use DestructMessageAwareTrait; } -class Value extends \V8\Value { +class UndefinedValue extends \V8\UndefinedValue { use DestructMessageAwareTrait; } diff --git a/tests/V8FunctionCallbackInfo.phpt b/tests/V8FunctionCallbackInfo.phpt index 4274b23..569e5fd 100644 --- a/tests/V8FunctionCallbackInfo.phpt +++ b/tests/V8FunctionCallbackInfo.phpt @@ -254,7 +254,7 @@ object(V8\FunctionCallbackInfo)#10 (8) { } } ["new_target":"V8\FunctionCallbackInfo":private]=> - object(V8\Value)#14 (1) { + object(V8\UndefinedValue)#14 (1) { ["isolate":"V8\Value":private]=> object(v8Tests\TrackingDtors\Isolate)#2 (5) { ["snapshot":"V8\Isolate":private]=> @@ -495,7 +495,7 @@ object(V8\FunctionCallbackInfo)#10 (8) { } } ["new_target":"V8\FunctionCallbackInfo":private]=> - object(V8\Value)#14 (1) { + object(V8\UndefinedValue)#14 (1) { ["isolate":"V8\Value":private]=> object(v8Tests\TrackingDtors\Isolate)#2 (5) { ["snapshot":"V8\Isolate":private]=> diff --git a/tests/V8FunctionObject_Call.phpt b/tests/V8FunctionObject_Call.phpt index 351d8d5..d2024df 100644 --- a/tests/V8FunctionObject_Call.phpt +++ b/tests/V8FunctionObject_Call.phpt @@ -127,7 +127,7 @@ $v8_helper->CHECK_EQ(10.11, $a4->Get($context, new \V8\IntegerValue($isolate, 3) $helper->line(); // Local r1 = ReturnThisSloppy->Call(v8::Undefined(isolate), 0, NULL); -$r1 = $ReturnThisSloppy->Call($context, new \V8\Value($isolate), []); +$r1 = $ReturnThisSloppy->Call($context, new \V8\UndefinedValue($isolate), []); // CHECK(r1->StrictEquals(context->Global())); $v8_helper->CHECK($r1->StrictEquals($context->GlobalObject()), '$r1->StrictEquals($context->GlobalObject())'); // Local r2 = ReturnThisSloppy->Call(v8::Null(isolate), 0, NULL); @@ -165,7 +165,7 @@ $v8_helper->CHECK($r5->ValueOf(), '$r5->ValueOf()'); $helper->line(); // Local r6 = ReturnThisStrict->Call(v8::Undefined(isolate), 0, NULL); -$r6 = $ReturnThisStrict->Call($context, new \V8\Value($isolate), []); +$r6 = $ReturnThisStrict->Call($context, new \V8\UndefinedValue($isolate), []); // CHECK(r6->IsUndefined()); $v8_helper->CHECK($r6->IsUndefined(), '$r6->IsUndefined()'); // Local r7 = ReturnThisStrict->Call(v8::Null(isolate), 0, NULL); diff --git a/tests/V8FunctionObject_Call_bad_args.phpt b/tests/V8FunctionObject_Call_bad_args.phpt index cb1209b..1c3c8fb 100644 --- a/tests/V8FunctionObject_Call_bad_args.phpt +++ b/tests/V8FunctionObject_Call_bad_args.phpt @@ -56,7 +56,7 @@ try { } ?> --EXPECT-- -TypeError: Argument 3 passed to V8\FunctionObject::Call() should be array of \V8\Value objects, integer given at 0 offset -TypeError: Argument 3 passed to V8\FunctionObject::Call() should be array of \V8\Value objects, instance of stdClass given at 0 offset +TypeError: Argument 3 passed to V8\FunctionObject::Call() must be an array of \V8\Value objects, integer given at 0 offset +TypeError: Argument 3 passed to V8\FunctionObject::Call() must be an array of \V8\Value objects, instance of stdClass given at 0 offset V8\Exceptions\Exception: Value is empty. Forgot to call parent::__construct()?: argument 3 passed to V8\FunctionObject::Call() at 0 offset V8\Exceptions\Exception: Isolates mismatch: argument 3 passed to V8\FunctionObject::Call() at 0 offset diff --git a/tests/V8FunctionTemplate_Set.phpt b/tests/V8FunctionTemplate_Set.phpt new file mode 100644 index 0000000..27ae2da --- /dev/null +++ b/tests/V8FunctionTemplate_Set.phpt @@ -0,0 +1,58 @@ +--TEST-- +V8\FunctionTemplate::Set() +--SKIPIF-- + +--FILE-- +injectConsoleLog($context); + +// Tests: + +$ft = new \V8\FunctionTemplate($isolate); +$ft->SetClassName(new \V8\StringValue($isolate, 'Test')); + +$proto = $ft->PrototypeTemplate(); + +$f = new \V8\FunctionObject($context, function (\V8\FunctionCallbackInfo $args) { +}); + +try { + $proto->Set(new \V8\StringValue($isolate, 'foo'), $f); +} catch (TypeError $e) { + $helper->exception_export($e); +} + +$ftpl2 = new \V8\FunctionTemplate($isolate, function (\V8\FunctionCallbackInfo $args) { + var_dump($args->This(), $args->Holder(), $args->NewTarget()); +}); + +$proto->Set(new \V8\StringValue($isolate, 'foo'), $ftpl2); + +$context->GlobalObject()->Set($context, new \V8\StringValue($isolate, 't'), $ft->GetFunction($context)); + + +$v8_helper->CompileRun($context, ' +console.log(t); +let nt = new t(); +console.log(nt); +console.log(nt.foo); +'); + + +?> +--EXPECT-- +TypeError: Argument 3 passed to V8\ObjectTemplate::Set() must be an instance of \V8\PrimitiveValue or \V8\Template, instance of V8\FunctionObject given +function Test() { [native code] } +[object Test] +function foo() { [native code] } diff --git a/tests/V8NameValue.phpt b/tests/V8NameValue.phpt deleted file mode 100644 index 561dab2..0000000 --- a/tests/V8NameValue.phpt +++ /dev/null @@ -1,236 +0,0 @@ ---TEST-- -V8\NameValue ---SKIPIF-- - ---FILE-- -header('Object representation'); -$helper->dump($value); -$helper->space(); - -$helper->assert('NameValue extends PrimitiveValue', $value instanceof \V8\PrimitiveValue); -$helper->line(); - -$helper->header('Accessors'); -$helper->method_matches($value, 'GetIsolate', $isolate); -$helper->space(); - -$helper->header('Getters'); -$helper->assert('GetIdentityHash is integer', gettype($value->GetIdentityHash()), 'integer'); -$helper->space(); - - -$v8_helper->run_checks($value); - -$global_template = new \V8\ObjectTemplate($isolate); -$context = new \V8\Context($isolate, $global_template); - - -$helper->header('Primitive converters'); -$helper->method_export($value, 'BooleanValue', [$context]); -$helper->method_export($value, 'NumberValue', [$context]); -$helper->space(); - - -$string = $value->ToString($context); - -$helper->header(get_class($value) .'::ToString() converting'); -$helper->dump($string); -$helper->dump($string->Value()); -$helper->space(); - -$v8_helper->run_checks($value, 'Checkers after ToString() converting'); - -$helper->header(get_class($value) .'::ToObject() converting'); -try { - $object = $value->ToObject($context); -} catch (Exception $e) { - $helper->exception_export($e); -} -$helper->space(); - - -?> ---EXPECT-- -Object representation: ----------------------- -object(V8\NameValue)#4 (1) { - ["isolate":"V8\Value":private]=> - object(V8\Isolate)#3 (5) { - ["snapshot":"V8\Isolate":private]=> - NULL - ["time_limit":"V8\Isolate":private]=> - float(0) - ["time_limit_hit":"V8\Isolate":private]=> - bool(false) - ["memory_limit":"V8\Isolate":private]=> - int(0) - ["memory_limit_hit":"V8\Isolate":private]=> - bool(false) - } -} - - -NameValue extends PrimitiveValue: ok - -Accessors: ----------- -V8\NameValue::GetIsolate() matches expected value - - -Getters: --------- -GetIdentityHash is integer: ok - - -Checks on V8\NameValue: ------------------------ -V8\NameValue(V8\Value)->TypeOf(): V8\StringValue->Value(): string(9) "undefined" - -V8\NameValue(V8\Value)->IsUndefined(): bool(true) -V8\NameValue(V8\Value)->IsNull(): bool(false) -V8\NameValue(V8\Value)->IsNullOrUndefined(): bool(true) -V8\NameValue(V8\Value)->IsTrue(): bool(false) -V8\NameValue(V8\Value)->IsFalse(): bool(false) -V8\NameValue(V8\Value)->IsName(): bool(false) -V8\NameValue(V8\Value)->IsString(): bool(false) -V8\NameValue(V8\Value)->IsSymbol(): bool(false) -V8\NameValue(V8\Value)->IsFunction(): bool(false) -V8\NameValue(V8\Value)->IsArray(): bool(false) -V8\NameValue(V8\Value)->IsObject(): bool(false) -V8\NameValue(V8\Value)->IsBoolean(): bool(false) -V8\NameValue(V8\Value)->IsNumber(): bool(false) -V8\NameValue(V8\Value)->IsInt32(): bool(false) -V8\NameValue(V8\Value)->IsUint32(): bool(false) -V8\NameValue(V8\Value)->IsDate(): bool(false) -V8\NameValue(V8\Value)->IsArgumentsObject(): bool(false) -V8\NameValue(V8\Value)->IsBooleanObject(): bool(false) -V8\NameValue(V8\Value)->IsNumberObject(): bool(false) -V8\NameValue(V8\Value)->IsStringObject(): bool(false) -V8\NameValue(V8\Value)->IsSymbolObject(): bool(false) -V8\NameValue(V8\Value)->IsNativeError(): bool(false) -V8\NameValue(V8\Value)->IsRegExp(): bool(false) -V8\NameValue(V8\Value)->IsAsyncFunction(): bool(false) -V8\NameValue(V8\Value)->IsGeneratorFunction(): bool(false) -V8\NameValue(V8\Value)->IsGeneratorObject(): bool(false) -V8\NameValue(V8\Value)->IsPromise(): bool(false) -V8\NameValue(V8\Value)->IsMap(): bool(false) -V8\NameValue(V8\Value)->IsSet(): bool(false) -V8\NameValue(V8\Value)->IsMapIterator(): bool(false) -V8\NameValue(V8\Value)->IsSetIterator(): bool(false) -V8\NameValue(V8\Value)->IsWeakMap(): bool(false) -V8\NameValue(V8\Value)->IsWeakSet(): bool(false) -V8\NameValue(V8\Value)->IsArrayBuffer(): bool(false) -V8\NameValue(V8\Value)->IsArrayBufferView(): bool(false) -V8\NameValue(V8\Value)->IsTypedArray(): bool(false) -V8\NameValue(V8\Value)->IsUint8Array(): bool(false) -V8\NameValue(V8\Value)->IsUint8ClampedArray(): bool(false) -V8\NameValue(V8\Value)->IsInt8Array(): bool(false) -V8\NameValue(V8\Value)->IsUint16Array(): bool(false) -V8\NameValue(V8\Value)->IsInt16Array(): bool(false) -V8\NameValue(V8\Value)->IsUint32Array(): bool(false) -V8\NameValue(V8\Value)->IsInt32Array(): bool(false) -V8\NameValue(V8\Value)->IsFloat32Array(): bool(false) -V8\NameValue(V8\Value)->IsFloat64Array(): bool(false) -V8\NameValue(V8\Value)->IsDataView(): bool(false) -V8\NameValue(V8\Value)->IsSharedArrayBuffer(): bool(false) -V8\NameValue(V8\Value)->IsProxy(): bool(false) - - -Primitive converters: ---------------------- -V8\NameValue(V8\Value)->BooleanValue(): bool(false) -V8\NameValue(V8\Value)->NumberValue(): float(NAN) - - -V8\NameValue::ToString() converting: ------------------------------------- -object(V8\StringValue)#79 (1) { - ["isolate":"V8\Value":private]=> - object(V8\Isolate)#3 (5) { - ["snapshot":"V8\Isolate":private]=> - NULL - ["time_limit":"V8\Isolate":private]=> - float(0) - ["time_limit_hit":"V8\Isolate":private]=> - bool(false) - ["memory_limit":"V8\Isolate":private]=> - int(0) - ["memory_limit_hit":"V8\Isolate":private]=> - bool(false) - } -} -string(9) "undefined" - - -Checkers after ToString() converting: -------------------------------------- -V8\NameValue(V8\Value)->TypeOf(): V8\StringValue->Value(): string(9) "undefined" - -V8\NameValue(V8\Value)->IsUndefined(): bool(true) -V8\NameValue(V8\Value)->IsNull(): bool(false) -V8\NameValue(V8\Value)->IsNullOrUndefined(): bool(true) -V8\NameValue(V8\Value)->IsTrue(): bool(false) -V8\NameValue(V8\Value)->IsFalse(): bool(false) -V8\NameValue(V8\Value)->IsName(): bool(false) -V8\NameValue(V8\Value)->IsString(): bool(false) -V8\NameValue(V8\Value)->IsSymbol(): bool(false) -V8\NameValue(V8\Value)->IsFunction(): bool(false) -V8\NameValue(V8\Value)->IsArray(): bool(false) -V8\NameValue(V8\Value)->IsObject(): bool(false) -V8\NameValue(V8\Value)->IsBoolean(): bool(false) -V8\NameValue(V8\Value)->IsNumber(): bool(false) -V8\NameValue(V8\Value)->IsInt32(): bool(false) -V8\NameValue(V8\Value)->IsUint32(): bool(false) -V8\NameValue(V8\Value)->IsDate(): bool(false) -V8\NameValue(V8\Value)->IsArgumentsObject(): bool(false) -V8\NameValue(V8\Value)->IsBooleanObject(): bool(false) -V8\NameValue(V8\Value)->IsNumberObject(): bool(false) -V8\NameValue(V8\Value)->IsStringObject(): bool(false) -V8\NameValue(V8\Value)->IsSymbolObject(): bool(false) -V8\NameValue(V8\Value)->IsNativeError(): bool(false) -V8\NameValue(V8\Value)->IsRegExp(): bool(false) -V8\NameValue(V8\Value)->IsAsyncFunction(): bool(false) -V8\NameValue(V8\Value)->IsGeneratorFunction(): bool(false) -V8\NameValue(V8\Value)->IsGeneratorObject(): bool(false) -V8\NameValue(V8\Value)->IsPromise(): bool(false) -V8\NameValue(V8\Value)->IsMap(): bool(false) -V8\NameValue(V8\Value)->IsSet(): bool(false) -V8\NameValue(V8\Value)->IsMapIterator(): bool(false) -V8\NameValue(V8\Value)->IsSetIterator(): bool(false) -V8\NameValue(V8\Value)->IsWeakMap(): bool(false) -V8\NameValue(V8\Value)->IsWeakSet(): bool(false) -V8\NameValue(V8\Value)->IsArrayBuffer(): bool(false) -V8\NameValue(V8\Value)->IsArrayBufferView(): bool(false) -V8\NameValue(V8\Value)->IsTypedArray(): bool(false) -V8\NameValue(V8\Value)->IsUint8Array(): bool(false) -V8\NameValue(V8\Value)->IsUint8ClampedArray(): bool(false) -V8\NameValue(V8\Value)->IsInt8Array(): bool(false) -V8\NameValue(V8\Value)->IsUint16Array(): bool(false) -V8\NameValue(V8\Value)->IsInt16Array(): bool(false) -V8\NameValue(V8\Value)->IsUint32Array(): bool(false) -V8\NameValue(V8\Value)->IsInt32Array(): bool(false) -V8\NameValue(V8\Value)->IsFloat32Array(): bool(false) -V8\NameValue(V8\Value)->IsFloat64Array(): bool(false) -V8\NameValue(V8\Value)->IsDataView(): bool(false) -V8\NameValue(V8\Value)->IsSharedArrayBuffer(): bool(false) -V8\NameValue(V8\Value)->IsProxy(): bool(false) - - -V8\NameValue::ToObject() converting: ------------------------------------- -V8\Exceptions\TryCatchException: TypeError: Cannot convert undefined or null to object diff --git a/tests/V8PrimitiveValue.phpt b/tests/V8PrimitiveValue.phpt deleted file mode 100644 index 42223f7..0000000 --- a/tests/V8PrimitiveValue.phpt +++ /dev/null @@ -1,226 +0,0 @@ ---TEST-- -V8\PrimitiveValue ---SKIPIF-- - ---FILE-- -header('Object representation'); -$helper->dump($value); -$helper->space(); - -$helper->assert('PrimitiveValue extends Value', $value instanceof \V8\Value); -$helper->line(); - -$helper->header('Accessors'); -$helper->method_matches($value, 'GetIsolate', $isolate); -$helper->space(); - -$v8_helper->run_checks($value); - -$global_template = new \V8\ObjectTemplate($isolate); -$context = new \V8\Context($isolate, $global_template); - - -$helper->header('Primitive converters'); -$helper->method_export($value, 'BooleanValue', [$context]); -$helper->method_export($value, 'NumberValue', [$context]); -$helper->space(); - - -$string = $value->ToString($context); - -$helper->header(get_class($value) .'::ToString() converting'); -$helper->dump($string); -$helper->dump($string->Value()); -$helper->space(); - -$v8_helper->run_checks($value, 'Checkers after ToString() converting'); - -$helper->header(get_class($value) .'::ToObject() converting'); -try { - $object = $value->ToObject($context); -} catch (Exception $e) { - $helper->exception_export($e); -} -$helper->space(); - - -?> ---EXPECT-- -Object representation: ----------------------- -object(V8\PrimitiveValue)#4 (1) { - ["isolate":"V8\Value":private]=> - object(V8\Isolate)#3 (5) { - ["snapshot":"V8\Isolate":private]=> - NULL - ["time_limit":"V8\Isolate":private]=> - float(0) - ["time_limit_hit":"V8\Isolate":private]=> - bool(false) - ["memory_limit":"V8\Isolate":private]=> - int(0) - ["memory_limit_hit":"V8\Isolate":private]=> - bool(false) - } -} - - -PrimitiveValue extends Value: ok - -Accessors: ----------- -V8\PrimitiveValue::GetIsolate() matches expected value - - -Checks on V8\PrimitiveValue: ----------------------------- -V8\PrimitiveValue(V8\Value)->TypeOf(): V8\StringValue->Value(): string(9) "undefined" - -V8\PrimitiveValue(V8\Value)->IsUndefined(): bool(true) -V8\PrimitiveValue(V8\Value)->IsNull(): bool(false) -V8\PrimitiveValue(V8\Value)->IsNullOrUndefined(): bool(true) -V8\PrimitiveValue(V8\Value)->IsTrue(): bool(false) -V8\PrimitiveValue(V8\Value)->IsFalse(): bool(false) -V8\PrimitiveValue(V8\Value)->IsName(): bool(false) -V8\PrimitiveValue(V8\Value)->IsString(): bool(false) -V8\PrimitiveValue(V8\Value)->IsSymbol(): bool(false) -V8\PrimitiveValue(V8\Value)->IsFunction(): bool(false) -V8\PrimitiveValue(V8\Value)->IsArray(): bool(false) -V8\PrimitiveValue(V8\Value)->IsObject(): bool(false) -V8\PrimitiveValue(V8\Value)->IsBoolean(): bool(false) -V8\PrimitiveValue(V8\Value)->IsNumber(): bool(false) -V8\PrimitiveValue(V8\Value)->IsInt32(): bool(false) -V8\PrimitiveValue(V8\Value)->IsUint32(): bool(false) -V8\PrimitiveValue(V8\Value)->IsDate(): bool(false) -V8\PrimitiveValue(V8\Value)->IsArgumentsObject(): bool(false) -V8\PrimitiveValue(V8\Value)->IsBooleanObject(): bool(false) -V8\PrimitiveValue(V8\Value)->IsNumberObject(): bool(false) -V8\PrimitiveValue(V8\Value)->IsStringObject(): bool(false) -V8\PrimitiveValue(V8\Value)->IsSymbolObject(): bool(false) -V8\PrimitiveValue(V8\Value)->IsNativeError(): bool(false) -V8\PrimitiveValue(V8\Value)->IsRegExp(): bool(false) -V8\PrimitiveValue(V8\Value)->IsAsyncFunction(): bool(false) -V8\PrimitiveValue(V8\Value)->IsGeneratorFunction(): bool(false) -V8\PrimitiveValue(V8\Value)->IsGeneratorObject(): bool(false) -V8\PrimitiveValue(V8\Value)->IsPromise(): bool(false) -V8\PrimitiveValue(V8\Value)->IsMap(): bool(false) -V8\PrimitiveValue(V8\Value)->IsSet(): bool(false) -V8\PrimitiveValue(V8\Value)->IsMapIterator(): bool(false) -V8\PrimitiveValue(V8\Value)->IsSetIterator(): bool(false) -V8\PrimitiveValue(V8\Value)->IsWeakMap(): bool(false) -V8\PrimitiveValue(V8\Value)->IsWeakSet(): bool(false) -V8\PrimitiveValue(V8\Value)->IsArrayBuffer(): bool(false) -V8\PrimitiveValue(V8\Value)->IsArrayBufferView(): bool(false) -V8\PrimitiveValue(V8\Value)->IsTypedArray(): bool(false) -V8\PrimitiveValue(V8\Value)->IsUint8Array(): bool(false) -V8\PrimitiveValue(V8\Value)->IsUint8ClampedArray(): bool(false) -V8\PrimitiveValue(V8\Value)->IsInt8Array(): bool(false) -V8\PrimitiveValue(V8\Value)->IsUint16Array(): bool(false) -V8\PrimitiveValue(V8\Value)->IsInt16Array(): bool(false) -V8\PrimitiveValue(V8\Value)->IsUint32Array(): bool(false) -V8\PrimitiveValue(V8\Value)->IsInt32Array(): bool(false) -V8\PrimitiveValue(V8\Value)->IsFloat32Array(): bool(false) -V8\PrimitiveValue(V8\Value)->IsFloat64Array(): bool(false) -V8\PrimitiveValue(V8\Value)->IsDataView(): bool(false) -V8\PrimitiveValue(V8\Value)->IsSharedArrayBuffer(): bool(false) -V8\PrimitiveValue(V8\Value)->IsProxy(): bool(false) - - -Primitive converters: ---------------------- -V8\PrimitiveValue(V8\Value)->BooleanValue(): bool(false) -V8\PrimitiveValue(V8\Value)->NumberValue(): float(NAN) - - -V8\PrimitiveValue::ToString() converting: ------------------------------------------ -object(V8\StringValue)#78 (1) { - ["isolate":"V8\Value":private]=> - object(V8\Isolate)#3 (5) { - ["snapshot":"V8\Isolate":private]=> - NULL - ["time_limit":"V8\Isolate":private]=> - float(0) - ["time_limit_hit":"V8\Isolate":private]=> - bool(false) - ["memory_limit":"V8\Isolate":private]=> - int(0) - ["memory_limit_hit":"V8\Isolate":private]=> - bool(false) - } -} -string(9) "undefined" - - -Checkers after ToString() converting: -------------------------------------- -V8\PrimitiveValue(V8\Value)->TypeOf(): V8\StringValue->Value(): string(9) "undefined" - -V8\PrimitiveValue(V8\Value)->IsUndefined(): bool(true) -V8\PrimitiveValue(V8\Value)->IsNull(): bool(false) -V8\PrimitiveValue(V8\Value)->IsNullOrUndefined(): bool(true) -V8\PrimitiveValue(V8\Value)->IsTrue(): bool(false) -V8\PrimitiveValue(V8\Value)->IsFalse(): bool(false) -V8\PrimitiveValue(V8\Value)->IsName(): bool(false) -V8\PrimitiveValue(V8\Value)->IsString(): bool(false) -V8\PrimitiveValue(V8\Value)->IsSymbol(): bool(false) -V8\PrimitiveValue(V8\Value)->IsFunction(): bool(false) -V8\PrimitiveValue(V8\Value)->IsArray(): bool(false) -V8\PrimitiveValue(V8\Value)->IsObject(): bool(false) -V8\PrimitiveValue(V8\Value)->IsBoolean(): bool(false) -V8\PrimitiveValue(V8\Value)->IsNumber(): bool(false) -V8\PrimitiveValue(V8\Value)->IsInt32(): bool(false) -V8\PrimitiveValue(V8\Value)->IsUint32(): bool(false) -V8\PrimitiveValue(V8\Value)->IsDate(): bool(false) -V8\PrimitiveValue(V8\Value)->IsArgumentsObject(): bool(false) -V8\PrimitiveValue(V8\Value)->IsBooleanObject(): bool(false) -V8\PrimitiveValue(V8\Value)->IsNumberObject(): bool(false) -V8\PrimitiveValue(V8\Value)->IsStringObject(): bool(false) -V8\PrimitiveValue(V8\Value)->IsSymbolObject(): bool(false) -V8\PrimitiveValue(V8\Value)->IsNativeError(): bool(false) -V8\PrimitiveValue(V8\Value)->IsRegExp(): bool(false) -V8\PrimitiveValue(V8\Value)->IsAsyncFunction(): bool(false) -V8\PrimitiveValue(V8\Value)->IsGeneratorFunction(): bool(false) -V8\PrimitiveValue(V8\Value)->IsGeneratorObject(): bool(false) -V8\PrimitiveValue(V8\Value)->IsPromise(): bool(false) -V8\PrimitiveValue(V8\Value)->IsMap(): bool(false) -V8\PrimitiveValue(V8\Value)->IsSet(): bool(false) -V8\PrimitiveValue(V8\Value)->IsMapIterator(): bool(false) -V8\PrimitiveValue(V8\Value)->IsSetIterator(): bool(false) -V8\PrimitiveValue(V8\Value)->IsWeakMap(): bool(false) -V8\PrimitiveValue(V8\Value)->IsWeakSet(): bool(false) -V8\PrimitiveValue(V8\Value)->IsArrayBuffer(): bool(false) -V8\PrimitiveValue(V8\Value)->IsArrayBufferView(): bool(false) -V8\PrimitiveValue(V8\Value)->IsTypedArray(): bool(false) -V8\PrimitiveValue(V8\Value)->IsUint8Array(): bool(false) -V8\PrimitiveValue(V8\Value)->IsUint8ClampedArray(): bool(false) -V8\PrimitiveValue(V8\Value)->IsInt8Array(): bool(false) -V8\PrimitiveValue(V8\Value)->IsUint16Array(): bool(false) -V8\PrimitiveValue(V8\Value)->IsInt16Array(): bool(false) -V8\PrimitiveValue(V8\Value)->IsUint32Array(): bool(false) -V8\PrimitiveValue(V8\Value)->IsInt32Array(): bool(false) -V8\PrimitiveValue(V8\Value)->IsFloat32Array(): bool(false) -V8\PrimitiveValue(V8\Value)->IsFloat64Array(): bool(false) -V8\PrimitiveValue(V8\Value)->IsDataView(): bool(false) -V8\PrimitiveValue(V8\Value)->IsSharedArrayBuffer(): bool(false) -V8\PrimitiveValue(V8\Value)->IsProxy(): bool(false) - - -V8\PrimitiveValue::ToObject() converting: ------------------------------------------ -V8\Exceptions\TryCatchException: TypeError: Cannot convert undefined or null to object diff --git a/tests/V8ScriptCompiler_CompileFunctionInContext.phpt b/tests/V8ScriptCompiler_CompileFunctionInContext.phpt index 818296a..adf34c4 100644 --- a/tests/V8ScriptCompiler_CompileFunctionInContext.phpt +++ b/tests/V8ScriptCompiler_CompileFunctionInContext.phpt @@ -134,8 +134,8 @@ Compile function: ok Compile function: ok Compile function: ok Compile function: ok -TypeError: Argument 3 passed to V8\ScriptCompiler::CompileFunctionInContext() should be array of \V8\StringValue, instance of V8\StringObject given at 0 offset -TypeError: Argument 4 passed to V8\ScriptCompiler::CompileFunctionInContext() should be array of \V8\ObjectValue, instance of V8\StringValue given at 0 offset +TypeError: Argument 3 passed to V8\ScriptCompiler::CompileFunctionInContext() must be an array of \V8\StringValue, instance of V8\StringObject given at 0 offset +TypeError: Argument 4 passed to V8\ScriptCompiler::CompileFunctionInContext() must be an array of \V8\ObjectValue, instance of V8\StringValue given at 0 offset Testing: diff --git a/tests/V8StringValue.phpt b/tests/V8StringValue.phpt index 05bb618..93d115c 100644 --- a/tests/V8StringValue.phpt +++ b/tests/V8StringValue.phpt @@ -29,6 +29,7 @@ $helper->dump($value); $helper->space(); $helper->assert('StringValue extends NameValue', $value instanceof \V8\NameValue); +$helper->assert('StringValue extends Value', $value instanceof \V8\Value); $helper->line(); $helper->header('Accessors'); @@ -131,6 +132,7 @@ object(V8\StringValue)#5 (1) { StringValue extends NameValue: ok +StringValue extends Value: ok Accessors: ---------- diff --git a/tests/V8SymbolValue.phpt b/tests/V8SymbolValue.phpt index 5ee65a2..da0a8fd 100644 --- a/tests/V8SymbolValue.phpt +++ b/tests/V8SymbolValue.phpt @@ -25,6 +25,7 @@ $helper->dump($value); $helper->space(); $helper->assert('SymbolValue extends NameValue', $value instanceof \V8\NameValue); +$helper->assert('SymbolValue extends Value', $value instanceof \V8\Value); $helper->line(); $helper->header('Accessors'); @@ -190,12 +191,13 @@ object(V8\SymbolValue)#4 (1) { SymbolValue extends NameValue: ok +SymbolValue extends Value: ok Accessors: ---------- V8\SymbolValue::GetIsolate() matches expected value V8\SymbolValue->Name(): - object(V8\Value)#92 (1) { + object(V8\UndefinedValue)#92 (1) { ["isolate":"V8\Value":private]=> object(V8\Isolate)#3 (5) { ["snapshot":"V8\Isolate":private]=> @@ -295,7 +297,7 @@ Accessors: ---------- V8\SymbolValue::GetIsolate() matches expected value V8\SymbolValue->Name(): - object(V8\Value)#7 (1) { + object(V8\UndefinedValue)#7 (1) { ["isolate":"V8\Value":private]=> object(V8\Isolate)#3 (5) { ["snapshot":"V8\Isolate":private]=> diff --git a/tests/V8UnboundScript.phpt b/tests/V8UnboundScript.phpt index f4c36c9..f849f97 100644 --- a/tests/V8UnboundScript.phpt +++ b/tests/V8UnboundScript.phpt @@ -39,7 +39,7 @@ $helper->method_matches($unbound, 'GetIsolate', $isolate); $helper->method_matches_instanceof($unbound, 'BindToContext', V8\Script::class, [$context]); $filter = new ArrayListFilter(['GetId', 'GetScriptName', 'GetSourceURL', 'GetSourceMappingURL'], false); -$finalizer = new CallChainFinalizer([\V8\StringValue::class => 'Value', \V8\Value::class => 'IsUndefined'], [], false); +$finalizer = new CallChainFinalizer([\V8\StringValue::class => 'Value', \V8\UndefinedValue::class => 'IsUndefined'], [], false); $helper->dump_object_methods($unbound, [], $filter, $finalizer); $helper->space(); @@ -92,9 +92,9 @@ Accessors: ---------- V8\UnboundScript::GetIsolate() matches expected value V8\UnboundScript::BindToContext() result is instance of V8\Script -V8\UnboundScript->GetId(): int(%d) +V8\UnboundScript->GetId(): int(19) V8\UnboundScript->GetScriptName(): V8\StringValue->Value(): string(7) "test.js" -V8\UnboundScript->GetSourceURL(): V8\Value->IsUndefined(): bool(true) +V8\UnboundScript->GetSourceURL(): V8\UndefinedValue->IsUndefined(): bool(true) V8\UnboundScript->GetSourceMappingURL(): V8\StringValue->Value(): string(0) "" diff --git a/tests/V8Undefined.phpt b/tests/V8Undefined.phpt new file mode 100644 index 0000000..2786d96 --- /dev/null +++ b/tests/V8Undefined.phpt @@ -0,0 +1,245 @@ +--TEST-- +V8\Undefined +--SKIPIF-- + +--FILE-- +header('Object representation'); +$helper->dump($value); +$helper->space(); + +$helper->assert('UndefinedValue extends PrimitiveValue', $value instanceof \V8\PrimitiveValue); +$helper->assert('UndefinedValue extends Value', $value instanceof \V8\Value); +$helper->assert('TypeOf returns StringValue', $value->TypeOf() instanceof \V8\StringValue); +$helper->line(); + +$helper->header('InstanceOf'); +try { + $value->InstanceOf($context, new \V8\ObjectValue($context)); +} catch (\V8\Exceptions\TryCatchException $e) { + $helper->exception_export($e); +} +$helper->assert('Default Value is not an instance of Function', !$value->InstanceOf($context, new \V8\FunctionObject($context, function(){}))); +$helper->line(); + +$helper->header('Accessors'); +$helper->method_matches($value, 'GetIsolate', $isolate); +$helper->space(); + +$v8_helper->run_checks($value); + +$global_template = new \V8\ObjectTemplate($isolate); +$context = new \V8\Context($isolate, $global_template); + + +$helper->header('Primitive converters'); +$helper->method_export($value, 'BooleanValue', [$context]); +$helper->method_export($value, 'NumberValue', [$context]); +$helper->space(); + + +$string = $value->ToString($context); + +$helper->header(get_class($value) .'::ToString() converting'); +$helper->dump($string); +$helper->dump($string->Value()); +$helper->space(); + +$v8_helper->run_checks($value, 'Checkers after ToString() converting'); + +$helper->header(get_class($value) .'::ToObject() converting'); +try { + $object = $value->ToObject($context); +} catch (Exception $e) { + $helper->exception_export($e); +} +$helper->space(); + + +?> +--EXPECT-- +Object representation: +---------------------- +object(V8\UndefinedValue)#5 (1) { + ["isolate":"V8\Value":private]=> + object(V8\Isolate)#3 (5) { + ["snapshot":"V8\Isolate":private]=> + NULL + ["time_limit":"V8\Isolate":private]=> + float(0) + ["time_limit_hit":"V8\Isolate":private]=> + bool(false) + ["memory_limit":"V8\Isolate":private]=> + int(0) + ["memory_limit_hit":"V8\Isolate":private]=> + bool(false) + } +} + + +UndefinedValue extends PrimitiveValue: ok +UndefinedValue extends Value: ok +TypeOf returns StringValue: ok + +InstanceOf: +----------- +V8\Exceptions\TryCatchException: TypeError: Right-hand side of 'instanceof' is not callable +Default Value is not an instance of Function: ok + +Accessors: +---------- +V8\UndefinedValue::GetIsolate() matches expected value + + +Checks on V8\UndefinedValue: +---------------------------- +V8\UndefinedValue(V8\Value)->TypeOf(): V8\StringValue->Value(): string(9) "undefined" + +V8\UndefinedValue(V8\Value)->IsUndefined(): bool(true) +V8\UndefinedValue(V8\Value)->IsNull(): bool(false) +V8\UndefinedValue(V8\Value)->IsNullOrUndefined(): bool(true) +V8\UndefinedValue(V8\Value)->IsTrue(): bool(false) +V8\UndefinedValue(V8\Value)->IsFalse(): bool(false) +V8\UndefinedValue(V8\Value)->IsName(): bool(false) +V8\UndefinedValue(V8\Value)->IsString(): bool(false) +V8\UndefinedValue(V8\Value)->IsSymbol(): bool(false) +V8\UndefinedValue(V8\Value)->IsFunction(): bool(false) +V8\UndefinedValue(V8\Value)->IsArray(): bool(false) +V8\UndefinedValue(V8\Value)->IsObject(): bool(false) +V8\UndefinedValue(V8\Value)->IsBoolean(): bool(false) +V8\UndefinedValue(V8\Value)->IsNumber(): bool(false) +V8\UndefinedValue(V8\Value)->IsInt32(): bool(false) +V8\UndefinedValue(V8\Value)->IsUint32(): bool(false) +V8\UndefinedValue(V8\Value)->IsDate(): bool(false) +V8\UndefinedValue(V8\Value)->IsArgumentsObject(): bool(false) +V8\UndefinedValue(V8\Value)->IsBooleanObject(): bool(false) +V8\UndefinedValue(V8\Value)->IsNumberObject(): bool(false) +V8\UndefinedValue(V8\Value)->IsStringObject(): bool(false) +V8\UndefinedValue(V8\Value)->IsSymbolObject(): bool(false) +V8\UndefinedValue(V8\Value)->IsNativeError(): bool(false) +V8\UndefinedValue(V8\Value)->IsRegExp(): bool(false) +V8\UndefinedValue(V8\Value)->IsAsyncFunction(): bool(false) +V8\UndefinedValue(V8\Value)->IsGeneratorFunction(): bool(false) +V8\UndefinedValue(V8\Value)->IsGeneratorObject(): bool(false) +V8\UndefinedValue(V8\Value)->IsPromise(): bool(false) +V8\UndefinedValue(V8\Value)->IsMap(): bool(false) +V8\UndefinedValue(V8\Value)->IsSet(): bool(false) +V8\UndefinedValue(V8\Value)->IsMapIterator(): bool(false) +V8\UndefinedValue(V8\Value)->IsSetIterator(): bool(false) +V8\UndefinedValue(V8\Value)->IsWeakMap(): bool(false) +V8\UndefinedValue(V8\Value)->IsWeakSet(): bool(false) +V8\UndefinedValue(V8\Value)->IsArrayBuffer(): bool(false) +V8\UndefinedValue(V8\Value)->IsArrayBufferView(): bool(false) +V8\UndefinedValue(V8\Value)->IsTypedArray(): bool(false) +V8\UndefinedValue(V8\Value)->IsUint8Array(): bool(false) +V8\UndefinedValue(V8\Value)->IsUint8ClampedArray(): bool(false) +V8\UndefinedValue(V8\Value)->IsInt8Array(): bool(false) +V8\UndefinedValue(V8\Value)->IsUint16Array(): bool(false) +V8\UndefinedValue(V8\Value)->IsInt16Array(): bool(false) +V8\UndefinedValue(V8\Value)->IsUint32Array(): bool(false) +V8\UndefinedValue(V8\Value)->IsInt32Array(): bool(false) +V8\UndefinedValue(V8\Value)->IsFloat32Array(): bool(false) +V8\UndefinedValue(V8\Value)->IsFloat64Array(): bool(false) +V8\UndefinedValue(V8\Value)->IsDataView(): bool(false) +V8\UndefinedValue(V8\Value)->IsSharedArrayBuffer(): bool(false) +V8\UndefinedValue(V8\Value)->IsProxy(): bool(false) + + +Primitive converters: +--------------------- +V8\UndefinedValue(V8\Value)->BooleanValue(): bool(false) +V8\UndefinedValue(V8\Value)->NumberValue(): float(NAN) + + +V8\UndefinedValue::ToString() converting: +----------------------------------------- +object(V8\StringValue)#88 (1) { + ["isolate":"V8\Value":private]=> + object(V8\Isolate)#3 (5) { + ["snapshot":"V8\Isolate":private]=> + NULL + ["time_limit":"V8\Isolate":private]=> + float(0) + ["time_limit_hit":"V8\Isolate":private]=> + bool(false) + ["memory_limit":"V8\Isolate":private]=> + int(0) + ["memory_limit_hit":"V8\Isolate":private]=> + bool(false) + } +} +string(9) "undefined" + + +Checkers after ToString() converting: +------------------------------------- +V8\UndefinedValue(V8\Value)->TypeOf(): V8\StringValue->Value(): string(9) "undefined" + +V8\UndefinedValue(V8\Value)->IsUndefined(): bool(true) +V8\UndefinedValue(V8\Value)->IsNull(): bool(false) +V8\UndefinedValue(V8\Value)->IsNullOrUndefined(): bool(true) +V8\UndefinedValue(V8\Value)->IsTrue(): bool(false) +V8\UndefinedValue(V8\Value)->IsFalse(): bool(false) +V8\UndefinedValue(V8\Value)->IsName(): bool(false) +V8\UndefinedValue(V8\Value)->IsString(): bool(false) +V8\UndefinedValue(V8\Value)->IsSymbol(): bool(false) +V8\UndefinedValue(V8\Value)->IsFunction(): bool(false) +V8\UndefinedValue(V8\Value)->IsArray(): bool(false) +V8\UndefinedValue(V8\Value)->IsObject(): bool(false) +V8\UndefinedValue(V8\Value)->IsBoolean(): bool(false) +V8\UndefinedValue(V8\Value)->IsNumber(): bool(false) +V8\UndefinedValue(V8\Value)->IsInt32(): bool(false) +V8\UndefinedValue(V8\Value)->IsUint32(): bool(false) +V8\UndefinedValue(V8\Value)->IsDate(): bool(false) +V8\UndefinedValue(V8\Value)->IsArgumentsObject(): bool(false) +V8\UndefinedValue(V8\Value)->IsBooleanObject(): bool(false) +V8\UndefinedValue(V8\Value)->IsNumberObject(): bool(false) +V8\UndefinedValue(V8\Value)->IsStringObject(): bool(false) +V8\UndefinedValue(V8\Value)->IsSymbolObject(): bool(false) +V8\UndefinedValue(V8\Value)->IsNativeError(): bool(false) +V8\UndefinedValue(V8\Value)->IsRegExp(): bool(false) +V8\UndefinedValue(V8\Value)->IsAsyncFunction(): bool(false) +V8\UndefinedValue(V8\Value)->IsGeneratorFunction(): bool(false) +V8\UndefinedValue(V8\Value)->IsGeneratorObject(): bool(false) +V8\UndefinedValue(V8\Value)->IsPromise(): bool(false) +V8\UndefinedValue(V8\Value)->IsMap(): bool(false) +V8\UndefinedValue(V8\Value)->IsSet(): bool(false) +V8\UndefinedValue(V8\Value)->IsMapIterator(): bool(false) +V8\UndefinedValue(V8\Value)->IsSetIterator(): bool(false) +V8\UndefinedValue(V8\Value)->IsWeakMap(): bool(false) +V8\UndefinedValue(V8\Value)->IsWeakSet(): bool(false) +V8\UndefinedValue(V8\Value)->IsArrayBuffer(): bool(false) +V8\UndefinedValue(V8\Value)->IsArrayBufferView(): bool(false) +V8\UndefinedValue(V8\Value)->IsTypedArray(): bool(false) +V8\UndefinedValue(V8\Value)->IsUint8Array(): bool(false) +V8\UndefinedValue(V8\Value)->IsUint8ClampedArray(): bool(false) +V8\UndefinedValue(V8\Value)->IsInt8Array(): bool(false) +V8\UndefinedValue(V8\Value)->IsUint16Array(): bool(false) +V8\UndefinedValue(V8\Value)->IsInt16Array(): bool(false) +V8\UndefinedValue(V8\Value)->IsUint32Array(): bool(false) +V8\UndefinedValue(V8\Value)->IsInt32Array(): bool(false) +V8\UndefinedValue(V8\Value)->IsFloat32Array(): bool(false) +V8\UndefinedValue(V8\Value)->IsFloat64Array(): bool(false) +V8\UndefinedValue(V8\Value)->IsDataView(): bool(false) +V8\UndefinedValue(V8\Value)->IsSharedArrayBuffer(): bool(false) +V8\UndefinedValue(V8\Value)->IsProxy(): bool(false) + + +V8\UndefinedValue::ToObject() converting: +----------------------------------------- +V8\Exceptions\TryCatchException: TypeError: Cannot convert undefined or null to object diff --git a/tests/V8Value_destruct.phpt b/tests/V8UndefinedValue_destruct.phpt similarity index 79% rename from tests/V8Value_destruct.phpt rename to tests/V8UndefinedValue_destruct.phpt index 0f40e8a..bb2e12b 100644 --- a/tests/V8Value_destruct.phpt +++ b/tests/V8UndefinedValue_destruct.phpt @@ -1,5 +1,5 @@ --TEST-- -V8\Value (destruct) +V8\UndefinedValue (destruct) --SKIPIF-- --FILE-- @@ -11,7 +11,7 @@ $helper = require '.testsuite.php'; require '.tracking_dtors.php'; $isolate = new V8\Isolate(); -$value = new \v8Tests\TrackingDtors\Value($isolate); +$value = new \v8Tests\TrackingDtors\UndefinedValue($isolate); $helper->dump($value); @@ -21,7 +21,7 @@ $value = null; echo "Done here", PHP_EOL; ?> --EXPECT-- -object(v8Tests\TrackingDtors\Value)#3 (1) { +object(v8Tests\TrackingDtors\UndefinedValue)#3 (1) { ["isolate":"V8\Value":private]=> object(V8\Isolate)#2 (5) { ["snapshot":"V8\Isolate":private]=> @@ -36,5 +36,5 @@ object(v8Tests\TrackingDtors\Value)#3 (1) { bool(false) } } -Value dies now! +UndefinedValue dies now! Done here diff --git a/tests/V8UndefinedValue_invalid_ctor_arg_type.phpt b/tests/V8UndefinedValue_invalid_ctor_arg_type.phpt new file mode 100644 index 0000000..2c42579 --- /dev/null +++ b/tests/V8UndefinedValue_invalid_ctor_arg_type.phpt @@ -0,0 +1,16 @@ +--TEST-- +V8\UndefinedValue::__construct() - with invalid arg type +--SKIPIF-- + +--FILE-- +getMessage(); +} +?> +--EXPECT-- +TypeError: Argument 1 passed to V8\UndefinedValue::__construct() must be an instance of V8\Isolate, instance of stdClass given diff --git a/tests/V8Value.phpt b/tests/V8Value.phpt deleted file mode 100644 index e22757b..0000000 --- a/tests/V8Value.phpt +++ /dev/null @@ -1,243 +0,0 @@ ---TEST-- -V8\Value ---SKIPIF-- - ---FILE-- -header('Object representation'); -$helper->dump($value); -$helper->space(); - -$helper->assert('Value extends Data', $value instanceof \V8\Data); -$helper->assert('TypeOf returns StringValue', $value->TypeOf() instanceof \V8\StringValue); -$helper->line(); - -$helper->header('InstanceOf'); -try { - $value->InstanceOf($context, new \V8\ObjectValue($context)); -} catch (\V8\Exceptions\TryCatchException $e) { - $helper->exception_export($e); -} -$helper->assert('Default Value is not an instance of Function', !$value->InstanceOf($context, new \V8\FunctionObject($context, function(){}))); -$helper->line(); - -$helper->header('Accessors'); -$helper->method_matches($value, 'GetIsolate', $isolate); -$helper->space(); - -$v8_helper->run_checks($value); - -$global_template = new \V8\ObjectTemplate($isolate); -$context = new \V8\Context($isolate, $global_template); - - -$helper->header('Primitive converters'); -$helper->method_export($value, 'BooleanValue', [$context]); -$helper->method_export($value, 'NumberValue', [$context]); -$helper->space(); - - -$string = $value->ToString($context); - -$helper->header(get_class($value) .'::ToString() converting'); -$helper->dump($string); -$helper->dump($string->Value()); -$helper->space(); - -$v8_helper->run_checks($value, 'Checkers after ToString() converting'); - -$helper->header(get_class($value) .'::ToObject() converting'); -try { - $object = $value->ToObject($context); -} catch (Exception $e) { - $helper->exception_export($e); -} -$helper->space(); - - -?> ---EXPECT-- -Object representation: ----------------------- -object(V8\Value)#5 (1) { - ["isolate":"V8\Value":private]=> - object(V8\Isolate)#3 (5) { - ["snapshot":"V8\Isolate":private]=> - NULL - ["time_limit":"V8\Isolate":private]=> - float(0) - ["time_limit_hit":"V8\Isolate":private]=> - bool(false) - ["memory_limit":"V8\Isolate":private]=> - int(0) - ["memory_limit_hit":"V8\Isolate":private]=> - bool(false) - } -} - - -Value extends Data: ok -TypeOf returns StringValue: ok - -InstanceOf: ------------ -V8\Exceptions\TryCatchException: TypeError: Right-hand side of 'instanceof' is not callable -Default Value is not an instance of Function: ok - -Accessors: ----------- -V8\Value::GetIsolate() matches expected value - - -Checks on V8\Value: -------------------- -V8\Value->TypeOf(): V8\StringValue->Value(): string(9) "undefined" - -V8\Value->IsUndefined(): bool(true) -V8\Value->IsNull(): bool(false) -V8\Value->IsNullOrUndefined(): bool(true) -V8\Value->IsTrue(): bool(false) -V8\Value->IsFalse(): bool(false) -V8\Value->IsName(): bool(false) -V8\Value->IsString(): bool(false) -V8\Value->IsSymbol(): bool(false) -V8\Value->IsFunction(): bool(false) -V8\Value->IsArray(): bool(false) -V8\Value->IsObject(): bool(false) -V8\Value->IsBoolean(): bool(false) -V8\Value->IsNumber(): bool(false) -V8\Value->IsInt32(): bool(false) -V8\Value->IsUint32(): bool(false) -V8\Value->IsDate(): bool(false) -V8\Value->IsArgumentsObject(): bool(false) -V8\Value->IsBooleanObject(): bool(false) -V8\Value->IsNumberObject(): bool(false) -V8\Value->IsStringObject(): bool(false) -V8\Value->IsSymbolObject(): bool(false) -V8\Value->IsNativeError(): bool(false) -V8\Value->IsRegExp(): bool(false) -V8\Value->IsAsyncFunction(): bool(false) -V8\Value->IsGeneratorFunction(): bool(false) -V8\Value->IsGeneratorObject(): bool(false) -V8\Value->IsPromise(): bool(false) -V8\Value->IsMap(): bool(false) -V8\Value->IsSet(): bool(false) -V8\Value->IsMapIterator(): bool(false) -V8\Value->IsSetIterator(): bool(false) -V8\Value->IsWeakMap(): bool(false) -V8\Value->IsWeakSet(): bool(false) -V8\Value->IsArrayBuffer(): bool(false) -V8\Value->IsArrayBufferView(): bool(false) -V8\Value->IsTypedArray(): bool(false) -V8\Value->IsUint8Array(): bool(false) -V8\Value->IsUint8ClampedArray(): bool(false) -V8\Value->IsInt8Array(): bool(false) -V8\Value->IsUint16Array(): bool(false) -V8\Value->IsInt16Array(): bool(false) -V8\Value->IsUint32Array(): bool(false) -V8\Value->IsInt32Array(): bool(false) -V8\Value->IsFloat32Array(): bool(false) -V8\Value->IsFloat64Array(): bool(false) -V8\Value->IsDataView(): bool(false) -V8\Value->IsSharedArrayBuffer(): bool(false) -V8\Value->IsProxy(): bool(false) - - -Primitive converters: ---------------------- -V8\Value->BooleanValue(): bool(false) -V8\Value->NumberValue(): float(NAN) - - -V8\Value::ToString() converting: --------------------------------- -object(V8\StringValue)#88 (1) { - ["isolate":"V8\Value":private]=> - object(V8\Isolate)#3 (5) { - ["snapshot":"V8\Isolate":private]=> - NULL - ["time_limit":"V8\Isolate":private]=> - float(0) - ["time_limit_hit":"V8\Isolate":private]=> - bool(false) - ["memory_limit":"V8\Isolate":private]=> - int(0) - ["memory_limit_hit":"V8\Isolate":private]=> - bool(false) - } -} -string(9) "undefined" - - -Checkers after ToString() converting: -------------------------------------- -V8\Value->TypeOf(): V8\StringValue->Value(): string(9) "undefined" - -V8\Value->IsUndefined(): bool(true) -V8\Value->IsNull(): bool(false) -V8\Value->IsNullOrUndefined(): bool(true) -V8\Value->IsTrue(): bool(false) -V8\Value->IsFalse(): bool(false) -V8\Value->IsName(): bool(false) -V8\Value->IsString(): bool(false) -V8\Value->IsSymbol(): bool(false) -V8\Value->IsFunction(): bool(false) -V8\Value->IsArray(): bool(false) -V8\Value->IsObject(): bool(false) -V8\Value->IsBoolean(): bool(false) -V8\Value->IsNumber(): bool(false) -V8\Value->IsInt32(): bool(false) -V8\Value->IsUint32(): bool(false) -V8\Value->IsDate(): bool(false) -V8\Value->IsArgumentsObject(): bool(false) -V8\Value->IsBooleanObject(): bool(false) -V8\Value->IsNumberObject(): bool(false) -V8\Value->IsStringObject(): bool(false) -V8\Value->IsSymbolObject(): bool(false) -V8\Value->IsNativeError(): bool(false) -V8\Value->IsRegExp(): bool(false) -V8\Value->IsAsyncFunction(): bool(false) -V8\Value->IsGeneratorFunction(): bool(false) -V8\Value->IsGeneratorObject(): bool(false) -V8\Value->IsPromise(): bool(false) -V8\Value->IsMap(): bool(false) -V8\Value->IsSet(): bool(false) -V8\Value->IsMapIterator(): bool(false) -V8\Value->IsSetIterator(): bool(false) -V8\Value->IsWeakMap(): bool(false) -V8\Value->IsWeakSet(): bool(false) -V8\Value->IsArrayBuffer(): bool(false) -V8\Value->IsArrayBufferView(): bool(false) -V8\Value->IsTypedArray(): bool(false) -V8\Value->IsUint8Array(): bool(false) -V8\Value->IsUint8ClampedArray(): bool(false) -V8\Value->IsInt8Array(): bool(false) -V8\Value->IsUint16Array(): bool(false) -V8\Value->IsInt16Array(): bool(false) -V8\Value->IsUint32Array(): bool(false) -V8\Value->IsInt32Array(): bool(false) -V8\Value->IsFloat32Array(): bool(false) -V8\Value->IsFloat64Array(): bool(false) -V8\Value->IsDataView(): bool(false) -V8\Value->IsSharedArrayBuffer(): bool(false) -V8\Value->IsProxy(): bool(false) - - -V8\Value::ToObject() converting: --------------------------------- -V8\Exceptions\TryCatchException: TypeError: Cannot convert undefined or null to object diff --git a/tests/V8Value_invalid_ctor_arg_type.phpt b/tests/V8Value_invalid_ctor_arg_type.phpt deleted file mode 100644 index 6698b01..0000000 --- a/tests/V8Value_invalid_ctor_arg_type.phpt +++ /dev/null @@ -1,16 +0,0 @@ ---TEST-- -V8\Value::__construct() - with invalid arg type ---SKIPIF-- - ---FILE-- -getMessage(); -} -?> ---EXPECT-- -TypeError: Argument 1 passed to V8\Value::__construct() must be an instance of V8\Isolate, instance of stdClass given diff --git a/v8.cc b/v8.cc index 66603f8..da47596 100644 --- a/v8.cc +++ b/v8.cc @@ -36,6 +36,7 @@ #include "php_v8_cached_data.h" #include "php_v8_source.h" #include "php_v8_script_compiler.h" +#include "php_v8_undefined.h" #include "php_v8_null.h" #include "php_v8_boolean.h" #include "php_v8_symbol.h" @@ -126,6 +127,7 @@ PHP_MINIT_FUNCTION(v8) PHP_MINIT(php_v8_data)(INIT_FUNC_ARGS_PASSTHRU); PHP_MINIT(php_v8_value)(INIT_FUNC_ARGS_PASSTHRU); PHP_MINIT(php_v8_primitive)(INIT_FUNC_ARGS_PASSTHRU); + PHP_MINIT(php_v8_undefined)(INIT_FUNC_ARGS_PASSTHRU); PHP_MINIT(php_v8_null)(INIT_FUNC_ARGS_PASSTHRU); PHP_MINIT(php_v8_boolean)(INIT_FUNC_ARGS_PASSTHRU); PHP_MINIT(php_v8_name)(INIT_FUNC_ARGS_PASSTHRU);