mirror of
https://github.com/php/php-src.git
synced 2025-08-16 05:58:45 +02:00
Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0: Private method incorrectly marked as "overwrites" in reflection
This commit is contained in:
commit
a795f3ebc6
3 changed files with 27 additions and 3 deletions
|
@ -793,7 +793,7 @@ static void _function_string(smart_str *str, zend_function *fptr, zend_class_ent
|
|||
} else if (fptr->common.scope->parent) {
|
||||
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 (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));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -66,7 +66,7 @@ Class [ <user> class B extends A ] {
|
|||
}
|
||||
|
||||
- Methods [1] {
|
||||
Method [ <user, overwrites A> private method f ] {
|
||||
Method [ <user> private method f ] {
|
||||
@@ %s 6 - 6
|
||||
}
|
||||
}
|
||||
|
@ -111,7 +111,7 @@ Class [ <user> class D extends C ] {
|
|||
}
|
||||
|
||||
- Methods [1] {
|
||||
Method [ <user, overwrites B> private method f ] {
|
||||
Method [ <user> private method f ] {
|
||||
@@ %s 12 - 12
|
||||
}
|
||||
}
|
||||
|
|
24
ext/reflection/tests/gh9409.phpt
Normal file
24
ext/reflection/tests/gh9409.phpt
Normal 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
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue