Merge branch 'PHP-8.2'

* PHP-8.2:
  Private method incorrectly marked as "overwrites" in reflection
This commit is contained in:
Ilija Tovilo 2022-09-08 10:44:50 +02:00
commit c200623f28
No known key found for this signature in database
GPG key ID: A4F5D403F118200A
3 changed files with 27 additions and 3 deletions

View file

@ -792,7 +792,7 @@ static void _function_string(smart_str *str, zend_function *fptr, zend_class_ent
} else if (fptr->common.scope->parent) { } else if (fptr->common.scope->parent) {
lc_name = zend_string_tolower(fptr->common.function_name); lc_name = zend_string_tolower(fptr->common.function_name);
if ((overwrites = zend_hash_find_ptr(&fptr->common.scope->parent->function_table, lc_name)) != NULL) { if ((overwrites = zend_hash_find_ptr(&fptr->common.scope->parent->function_table, lc_name)) != NULL) {
if (fptr->common.scope != overwrites->common.scope) { if (fptr->common.scope != overwrites->common.scope && !(overwrites->common.fn_flags & ZEND_ACC_PRIVATE)) {
smart_str_append_printf(str, ", overwrites %s", ZSTR_VAL(overwrites->common.scope->name)); smart_str_append_printf(str, ", overwrites %s", ZSTR_VAL(overwrites->common.scope->name));
} }
} }

View file

@ -66,7 +66,7 @@ Class [ <user> class B extends A ] {
} }
- Methods [1] { - Methods [1] {
Method [ <user, overwrites A> private method f ] { Method [ <user> private method f ] {
@@ %s 6 - 6 @@ %s 6 - 6
} }
} }
@ -111,7 +111,7 @@ Class [ <user> class D extends C ] {
} }
- Methods [1] { - Methods [1] {
Method [ <user, overwrites B> private method f ] { Method [ <user> private method f ] {
@@ %s 12 - 12 @@ %s 12 - 12
} }
} }

View file

@ -0,0 +1,24 @@
--TEST--
GH-9409: Private method is incorrectly dumped as "overwrites"
--FILE--
<?php
class A {
private function privateMethod() {}
}
class C extends A {
private function privateMethod() {}
}
echo (new ReflectionClass('A'))->getMethod('privateMethod');
echo (new ReflectionClass('C'))->getMethod('privateMethod');
?>
--EXPECTF--
Method [ <user> private method privateMethod ] {
@@ %s %d - %d
}
Method [ <user> private method privateMethod ] {
@@ %s %d - %d
}