phpv8/v8js

Dynamic Properties deprecation in PHP 8.2

stesie opened this issue · 4 comments

stesie commented

With PHP 8.2 the test suite actually works, but reports half of the tests failing, since they have deprecation notices like this:

Deprecated: Creation of dynamic property V8Js::$foo is deprecated

... because of this: https://php.watch/versions/8.2/dynamic-properties-deprecated

It's likely best to tag all V8Js classes with #[AllowDynamicProperties] attribute to omit this notice.
Need to find out how to programatically set this attribute in C++ code 🙂

Maybe register_class_stdClass can help to figure out:
Zend/zend_builtin_functions_arginfo.h

static zend_class_entry *register_class_stdClass(void)
{
	zend_class_entry ce, *class_entry;

	INIT_CLASS_ENTRY(ce, "stdClass", class_stdClass_methods);
	class_entry = zend_register_internal_class_ex(&ce, NULL);
	class_entry->ce_flags |= ZEND_ACC_ALLOW_DYNAMIC_PROPERTIES;

	zend_string *attribute_name_AllowDynamicProperties_class_stdClass = zend_string_init_interned("AllowDynamicProperties", sizeof("AllowDynamicProperties") - 1, 1);
	zend_add_class_attribute(class_entry, attribute_name_AllowDynamicProperties_class_stdClass, 0);
	zend_string_release(attribute_name_AllowDynamicProperties_class_stdClass);

	return class_entry;
}

I will run some tests.

I've made the necessary changes for php8.2
#505
But some test are failling.

=====================================================================
FAILED TEST SUMMARY
---------------------------------------------------------------------
Test V8::executeString() : Use ArrayAccess with JavaScript native push method [tests/array_access_002.phpt]
Test V8::executeString() : Test PHP object construction controlled by JavaScript (protected ctor) [tests/js-construct-protected-ctor.phpt]
Test V8::executeString() : var_dump [tests/var_dump.phpt]
=====================================================================

Was this already fixed by #505 and #508? Basically, are all known PHP 8.2 issues fixed?

stesie commented

@colinmollenhour yes, all issues should be resolved. Just forgot to close this ticket.