[php] Fix -prefix when there are subclasses

The calls to the parent class' magic __get, __set and __isset methods
weren't getting the prefix.
This commit is contained in:
Olly Betts 2021-05-12 14:58:59 +12:00
commit ead90be779
3 changed files with 10 additions and 4 deletions

View file

@ -5,7 +5,7 @@ require "tests.php";
// No new functions
check::functions(array());
// New classes
check::classes(array('ProjectFoo'));
check::classes(array('ProjectBar','ProjectFoo'));
// No new vars
check::globals(array());

View file

@ -11,4 +11,10 @@ public:
}
};
// This failed in git pre 4.1.0 - the calls to the parent class' magic __get,
// __set and __isset methods weren't getting the prefix.
class Bar : public Foo {
public:
};
%}

View file

@ -941,7 +941,7 @@ public:
}
Printf(f->code, "} else {\n");
if (base_class) {
Printf(f->code, "PHP_MN(%s___set)(INTERNAL_FUNCTION_PARAM_PASSTHRU);\n}\n", base_class);
Printf(f->code, "PHP_MN(%s%s___set)(INTERNAL_FUNCTION_PARAM_PASSTHRU);\n}\n", prefix, base_class);
} else {
Printf(f->code, "add_property_zval_ex(ZEND_THIS, ZSTR_VAL(arg2), ZSTR_LEN(arg2), &args[1]);\n}\n");
}
@ -974,7 +974,7 @@ public:
Printf(f->code, "if(arg->newobject) {\nRETVAL_LONG(1);\n}\nelse {\nRETVAL_LONG(0);\n}\n}\n\n");
Printf(f->code, "else {\n");
if (base_class) {
Printf(f->code, "PHP_MN(%s___get)(INTERNAL_FUNCTION_PARAM_PASSTHRU);\n}\n", base_class);
Printf(f->code, "PHP_MN(%s%s___get)(INTERNAL_FUNCTION_PARAM_PASSTHRU);\n}\n", prefix, base_class);
} else {
// __get is only called if the property isn't set on the zend_object.
Printf(f->code, "RETVAL_NULL();\n}\n");
@ -1008,7 +1008,7 @@ public:
}
Printf(f->code, "else {\n");
if (base_class) {
Printf(f->code, "PHP_MN(%s___isset)(INTERNAL_FUNCTION_PARAM_PASSTHRU);\n}\n", base_class);
Printf(f->code, "PHP_MN(%s%s___isset)(INTERNAL_FUNCTION_PARAM_PASSTHRU);\n}\n", prefix, base_class);
} else {
// __isset is only called if the property isn't set on the zend_object.
Printf(f->code, "RETVAL_FALSE;\n}\n");