mirror of
https://github.com/phpv8/v8js.git
synced 2024-09-08 00:25:19 +00:00
* Added AllowDynamicPropertis on V8Js, V8Object and V8Function
* Added #[AllowDynamicProperties] on test classes that uses Dynamic Properties
This commit is contained in:
parent
7c40690ec0
commit
83431fbd52
@ -5,6 +5,7 @@ Test V8::executeString() : has_property after dispose
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
#[AllowDynamicProperties]
|
||||
class Foo {
|
||||
function callMe($x) {
|
||||
var_dump(property_exists($x, 'bla'));
|
||||
|
@ -5,6 +5,7 @@ Test V8::executeString() : Issue #250 (early free of array)
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
#[AllowDynamicProperties]
|
||||
class TestObject {
|
||||
|
||||
private $data = [];
|
||||
@ -55,9 +56,9 @@ try {
|
||||
?>
|
||||
===EOF===
|
||||
--EXPECTF--
|
||||
Fatal error: Uncaught Error: Attempt to modify property "b" on null in %s%eissue_250_001.php:9
|
||||
Fatal error: Uncaught Error: Attempt to modify property "b" on null in %s%eissue_250_001.php:10
|
||||
Stack trace:
|
||||
#0 [internal function]: TestObject->setTitle('ouch')
|
||||
#1 %s%eissue_250_001.php(44): V8Js->executeString(' var v1 = se...')
|
||||
#1 %s%eissue_250_001.php(45): V8Js->executeString(' var v1 = se...')
|
||||
#2 {main}
|
||||
thrown in %s%eissue_250_001.php on line 9
|
||||
thrown in %s%eissue_250_001.php on line 10
|
||||
|
@ -5,6 +5,7 @@ Test V8::executeString() : Property visibility - has property
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
#[AllowDynamicProperties]
|
||||
class Foo {
|
||||
private $privBar = "privBar";
|
||||
protected $protBar = "protBar";
|
||||
|
@ -5,6 +5,7 @@ Test V8::executeString() : Property visibility - set
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
#[AllowDynamicProperties]
|
||||
class Foo {
|
||||
private $privBar = "privBar";
|
||||
protected $protBar = "protBar";
|
||||
|
@ -5,6 +5,7 @@ Test V8::executeString() : Use after dispose
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
#[AllowDynamicProperties]
|
||||
class Foo {
|
||||
function callMe($x) {
|
||||
var_dump($x);
|
||||
|
@ -34,6 +34,7 @@ extern "C" {
|
||||
#include "zend_closures.h"
|
||||
#include "ext/spl/spl_exceptions.h"
|
||||
#include "zend_exceptions.h"
|
||||
#include "zend_attributes.h"
|
||||
}
|
||||
|
||||
#define PHP_V8JS_SCRIPT_RES_NAME "V8Js script"
|
||||
@ -1059,6 +1060,14 @@ PHP_MINIT_FUNCTION(v8js_class) /* {{{ */
|
||||
php_ce_v8js = zend_register_internal_class(&ce);
|
||||
php_ce_v8js->create_object = v8js_new;
|
||||
|
||||
#if PHP_VERSION_ID >= 80200
|
||||
php_ce_v8js->ce_flags |= ZEND_ACC_ALLOW_DYNAMIC_PROPERTIES;
|
||||
|
||||
zend_string *attribute_name_AllowDynamicProperties_class_V8Js = zend_string_init_interned("AllowDynamicProperties", sizeof("AllowDynamicProperties") - 1, 1);
|
||||
zend_add_class_attribute(php_ce_v8js, attribute_name_AllowDynamicProperties_class_V8Js, 0);
|
||||
zend_string_release(attribute_name_AllowDynamicProperties_class_V8Js);
|
||||
#endif
|
||||
|
||||
/* V8Js handlers */
|
||||
memcpy(&v8js_object_handlers, zend_get_std_object_handlers(), sizeof(zend_object_handlers));
|
||||
v8js_object_handlers.clone_obj = NULL;
|
||||
|
@ -29,6 +29,7 @@ extern "C"
|
||||
#include "zend_closures.h"
|
||||
#include "ext/spl/spl_exceptions.h"
|
||||
#include "zend_exceptions.h"
|
||||
#include "zend_attributes.h"
|
||||
}
|
||||
|
||||
/* {{{ Class Entries */
|
||||
@ -899,11 +900,27 @@ PHP_MINIT_FUNCTION(v8js_v8object_class) /* {{{ */
|
||||
php_ce_v8object->ce_flags |= ZEND_ACC_FINAL;
|
||||
php_ce_v8object->create_object = v8js_v8object_new;
|
||||
|
||||
#if PHP_VERSION_ID >= 80200
|
||||
php_ce_v8object->ce_flags |= ZEND_ACC_ALLOW_DYNAMIC_PROPERTIES;
|
||||
|
||||
zend_string *attribute_name_AllowDynamicProperties_class_v8object = zend_string_init_interned("AllowDynamicProperties", sizeof("AllowDynamicProperties") - 1, 1);
|
||||
zend_add_class_attribute(php_ce_v8object, attribute_name_AllowDynamicProperties_class_v8object, 0);
|
||||
zend_string_release(attribute_name_AllowDynamicProperties_class_v8object);
|
||||
#endif
|
||||
|
||||
/* V8Function Class */
|
||||
INIT_CLASS_ENTRY(ce, "V8Function", v8js_v8function_methods);
|
||||
php_ce_v8function = zend_register_internal_class(&ce);
|
||||
php_ce_v8function->ce_flags |= ZEND_ACC_FINAL;
|
||||
php_ce_v8function->create_object = v8js_v8object_new;
|
||||
|
||||
#if PHP_VERSION_ID >= 80200
|
||||
php_ce_v8function->ce_flags |= ZEND_ACC_ALLOW_DYNAMIC_PROPERTIES;
|
||||
|
||||
zend_string *attribute_name_AllowDynamicProperties_class_v8function = zend_string_init_interned("AllowDynamicProperties", sizeof("AllowDynamicProperties") - 1, 1);
|
||||
zend_add_class_attribute(php_ce_v8function, attribute_name_AllowDynamicProperties_class_v8function, 0);
|
||||
zend_string_release(attribute_name_AllowDynamicProperties_class_v8function);
|
||||
#endif
|
||||
|
||||
/* V8Generator Class */
|
||||
INIT_CLASS_ENTRY(ce, "V8Generator", v8js_v8generator_methods);
|
||||
|
Loading…
Reference in New Issue
Block a user