[php] Fix handling of friend functions

We were incorrectly considering them as methods of the class they
are a friend of for the purposes of calculate PHP type declarations.
This commit is contained in:
Olly Betts 2022-07-23 14:51:10 +12:00
commit dce4254377

View file

@ -1253,7 +1253,13 @@ public:
// of a group so reset the phptype information. // of a group so reset the phptype information.
phptypes = NULL; phptypes = NULL;
String *key = NewStringf("%s:%s", class_name, wname); String *key;
if (class_name && !Equal(Getattr(n, "storage"), "friend")) {
key = NewStringf("%s:%s", class_name, wname);
} else {
key = NewStringf(":%s", wname);
}
PHPTypes *p = (PHPTypes*)GetVoid(all_phptypes, key); PHPTypes *p = (PHPTypes*)GetVoid(all_phptypes, key);
if (p) { if (p) {
// We already have an entry - this happens when overloads are created // We already have an entry - this happens when overloads are created
@ -1428,11 +1434,13 @@ public:
Wrapper_add_local(f, "upcall", "bool upcall = false"); Wrapper_add_local(f, "upcall", "bool upcall = false");
Printf(f->code, "upcall = (director && (director->swig_get_self()==Z_OBJ_P(ZEND_THIS)));\n"); Printf(f->code, "upcall = (director && (director->swig_get_self()==Z_OBJ_P(ZEND_THIS)));\n");
String *parent = class_name; if (class_name && !Equal(Getattr(n, "storage"), "friend")) {
while ((parent = Getattr(php_parent_class, parent)) != NULL) { String *parent = class_name;
// Mark this method name as having a directed descendent for all while ((parent = Getattr(php_parent_class, parent)) != NULL) {
// classes we're derived from. // Mark this method name as having a directed descendent for all
SetFlag(has_directed_descendent, NewStringf("%s:%s", parent, wname)); // classes we're derived from.
SetFlag(has_directed_descendent, NewStringf("%s:%s", parent, wname));
}
} }
} }