[php] Add php:allowdynamicproperties feature
This follows PHP 8.2 deprecating dynamic features. The new feature also provides a clean way to fix the remaining PHP test case failure under PHP 8.2.
This commit is contained in:
parent
20ed76a27b
commit
9a4dea06c8
4 changed files with 86 additions and 4 deletions
|
|
@ -1056,12 +1056,12 @@ public:
|
|||
" if (director) director->swig_disown();\n",
|
||||
"}\n", NIL);
|
||||
}
|
||||
Printf(f->code, "} else {\n");
|
||||
if (swig_base) {
|
||||
Printf(f->code, "PHP_MN(%s%s___set)(INTERNAL_FUNCTION_PARAM_PASSTHRU);\n}\n", prefix, swig_base);
|
||||
} else {
|
||||
Printf(f->code, "add_property_zval_ex(ZEND_THIS, ZSTR_VAL(arg2), ZSTR_LEN(arg2), &args[1]);\n}\n");
|
||||
Printf(f->code, "} else {\nPHP_MN(%s%s___set)(INTERNAL_FUNCTION_PARAM_PASSTHRU);\n", prefix, swig_base);
|
||||
} else if (Getattr(class_node, "feature:php:allowdynamicproperties")) {
|
||||
Printf(f->code, "} else {\nadd_property_zval_ex(ZEND_THIS, ZSTR_VAL(arg2), ZSTR_LEN(arg2), &args[1]);\n");
|
||||
}
|
||||
Printf(f->code, "}\n");
|
||||
|
||||
Printf(f->code, "fail:\n");
|
||||
Printf(f->code, "return;\n");
|
||||
|
|
@ -1777,6 +1777,15 @@ public:
|
|||
if (Getattr(n, "abstracts") && !GetFlag(n, "feature:notabstract")) {
|
||||
Printf(s_oinit, " SWIG_Php_ce_%s->ce_flags |= ZEND_ACC_EXPLICIT_ABSTRACT_CLASS;\n", class_name);
|
||||
}
|
||||
if (Getattr(n, "feature:php:allowdynamicproperties")) {
|
||||
Append(s_oinit, "#ifdef ZEND_ACC_ALLOW_DYNAMIC_PROPERTIES\n");
|
||||
Printf(s_oinit, " SWIG_Php_ce_%s->ce_flags |= ZEND_ACC_ALLOW_DYNAMIC_PROPERTIES;\n", class_name);
|
||||
Append(s_oinit, "#endif\n");
|
||||
} else {
|
||||
Append(s_oinit, "#ifdef ZEND_ACC_NO_DYNAMIC_PROPERTIES\n");
|
||||
Printf(s_oinit, " SWIG_Php_ce_%s->ce_flags |= ZEND_ACC_NO_DYNAMIC_PROPERTIES;\n", class_name);
|
||||
Append(s_oinit, "#endif\n");
|
||||
}
|
||||
String *swig_wrapped = swig_wrapped_interface_ce();
|
||||
Printv(s_oinit, " zend_do_implement_interface(SWIG_Php_ce_", class_name, ", &", swig_wrapped, ");\n", NIL);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue