diff --git a/tests/array_access.phpt b/tests/array_access.phpt index 75c0b91..c082e4b 100644 --- a/tests/array_access.phpt +++ b/tests/array_access.phpt @@ -37,6 +37,7 @@ $js = <<executeString($js); --EXPECT-- int(20) int(14) -string(11) "ArrayAccess" +string(5) "Array" int(20) int(14) +string(68) "19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0" ===EOF=== diff --git a/v8js_convert.cc b/v8js_convert.cc index c5bea76..2fc8fc0 100644 --- a/v8js_convert.cc +++ b/v8js_convert.cc @@ -956,10 +956,13 @@ static v8::Handle php_v8js_array_access_to_jsobj(zval *value, v8::Iso inst_tpl->SetAccessor(V8JS_STR("length"), php_v8js_array_access_length); inst_tpl->SetInternalFieldCount(1); - v8::Handle newobj = inst_tpl->NewInstance(); newobj->SetAlignedPointerInInternalField(0, value); + /* Change prototype of `newobj' to that of Array */ + v8::Local arr = v8::Array::New(isolate); + newobj->SetPrototype(arr->GetPrototype()); + return newobj; } /* }}} */