com php-src: Fix resolution of "parent" during inheritance check: Zend/tests/type_declarations/parent_is_not_proto.phpt Zend/zend_inheritance.c

From: Date: Wed, 08 May 2019 09:35:26 +0000
Subject: com php-src: Fix resolution of "parent" during inheritance check: Zend/tests/type_declarations/parent_is_not_proto.phpt Zend/zend_inheritance.c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-106066@lists.php.net to get a copy of this message
Commit: d19b6aa5ba6ea7b488cca748934264e11469f3d5 Author: Nikita Popov <nikita.ppv@gmail.com> Wed, 8 May 2019 11:33:13 +0200 Parents: 9977de00284c2b702e4aadfcc66069befa0aaf75 Branches: PHP-7.2 PHP-7.3 PHP-7.4 master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=d19b6aa5ba6ea7b488cca748934264e11469f3d5 Log: Fix resolution of "parent" during inheritance check We can't assume that the method we're checking against is part of the parent class... Changed paths: A Zend/tests/type_declarations/parent_is_not_proto.phpt M Zend/zend_inheritance.c Diff: diff --git a/Zend/tests/type_declarations/parent_is_not_proto.phpt b/Zend/tests/type_declarations/parent_is_not_proto.phpt new file mode 100644 index 0000000..f6ee536 --- /dev/null +++ b/Zend/tests/type_declarations/parent_is_not_proto.phpt @@ -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=== diff --git a/Zend/zend_inheritance.c b/Zend/zend_inheritance.c index 2d51ed1..fac74a2 100644 --- a/Zend/zend_inheritance.c +++ b/Zend/zend_inheritance.c @@ -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 {

« previous php.cvs (#106066) next »