1
0
mirror of https://github.com/php/php-src.git synced 2026-04-29 03:03:26 +02:00

Fix resolution of "parent" during inheritance check

We can't assume that the method we're checking against is part of
the parent class...
This commit is contained in:
Nikita Popov
2019-05-08 11:33:13 +02:00
parent 9977de0028
commit d19b6aa5ba
2 changed files with 19 additions and 2 deletions
@@ -0,0 +1,17 @@
--TEST--
The parent class is not necessarily the class of the prototype
--FILE--
<?php
class A {
function test(): B {}
}
class B extends A {}
class C extends B {
function test(): parent {}
}
?>
===DONE===
--EXPECT--
===DONE===
+2 -2
View File
@@ -193,8 +193,8 @@ static int zend_do_perform_type_hint_check(const zend_function *fe, zend_arg_inf
fe_class_name = ZEND_TYPE_NAME(fe_arg_info->type);
class_name = ZSTR_VAL(fe_class_name);
class_name_len = ZSTR_LEN(fe_class_name);
if (class_name_len == sizeof("parent")-1 && !strcasecmp(class_name, "parent") && proto->common.scope) {
fe_class_name = zend_string_copy(proto->common.scope->name);
if (class_name_len == sizeof("parent")-1 && !strcasecmp(class_name, "parent") && fe->common.scope && fe->common.scope->parent) {
fe_class_name = zend_string_copy(fe->common.scope->parent->name);
} else if (class_name_len == sizeof("self")-1 && !strcasecmp(class_name, "self") && fe->common.scope) {
fe_class_name = zend_string_copy(fe->common.scope->name);
} else {