mirror of
https://github.com/php/php-src.git
synced 2025-08-16 05:58:45 +02:00
Private method incorrectly marked as "overwrites" in reflection
Fix GH-9409 Closes GH-9469
This commit is contained in:
parent
6ac3f7c84d
commit
1435fc6262
4 changed files with 29 additions and 3 deletions
2
NEWS
2
NEWS
|
@ -25,6 +25,8 @@ PHP NEWS
|
||||||
- Reflection:
|
- Reflection:
|
||||||
. Fixed bug GH-8932 (ReflectionFunction provides no way to get the called
|
. Fixed bug GH-8932 (ReflectionFunction provides no way to get the called
|
||||||
class of a Closure). (cmb, Nicolas Grekas)
|
class of a Closure). (cmb, Nicolas Grekas)
|
||||||
|
. Fixed bug GH-9409 (Private method is incorrectly dumped as "overwrites").
|
||||||
|
(ilutov)
|
||||||
|
|
||||||
- Streams:
|
- Streams:
|
||||||
. Fixed bug GH-9316 ($http_response_header is wrong for long status line).
|
. Fixed bug GH-9316 ($http_response_header is wrong for long status line).
|
||||||
|
|
|
@ -784,7 +784,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));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
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