com php-src: Simplify method visibility checks: Zend/zend_obj ect_handlers.c

From: Date: Wed, 12 Sep 2018 05:31:01 +0000
Subject: com php-src: Simplify method visibility checks: Zend/zend_obj ect_handlers.c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-103074@lists.php.net to get a copy of this message
Commit: 73efd1b65120797dab253e78afe83049e62b0a79 Author: Dmitry Stogov <dmitry@zend.com> Wed, 12 Sep 2018 08:31:01 +0300 Parents: 34f4ecee2577bda39c0f86671244c8b0cb532a79 Branches: master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=73efd1b65120797dab253e78afe83049e62b0a79 Log: Simplify method visibility checks Changed paths: M Zend/zend_object_handlers.c Diff: diff --git a/Zend/zend_object_handlers.c b/Zend/zend_object_handlers.c index 4e982ba..f8700de 100644 --- a/Zend/zend_object_handlers.c +++ b/Zend/zend_object_handlers.c @@ -1109,19 +1109,15 @@ static zend_always_inline zend_function *zend_get_parent_private(zend_class_entr zval *func; zend_function *fbc; - ce = ce->parent; - while (ce) { - if (ce == scope) { - if ((func = zend_hash_find(&ce->function_table, function_name))) { - fbc = Z_FUNC_P(func); - if (fbc->common.fn_flags & ZEND_ACC_PRIVATE - && fbc->common.scope == scope) { - return fbc; - } + if (scope != ce && scope && is_derived_class(ce, scope)) { + func = zend_hash_find(&scope->function_table, function_name); + if (func != NULL) { + fbc = Z_FUNC_P(func); + if (fbc->common.fn_flags & ZEND_ACC_PRIVATE + && fbc->common.scope == scope) { + return fbc; } - break; } - ce = ce->parent; } return NULL; } @@ -1146,7 +1142,7 @@ ZEND_API int zend_check_private(zend_function *fbc, zend_class_entry *ce, zend_s * a private function with the same name that has the same scope. */ scope = zend_get_executed_scope(); - if (fbc->common.scope == ce && scope == ce) { + if (fbc->common.scope == scope) { /* rule #1 checks out ok, allow the function call */ return 1; } @@ -1272,7 +1268,7 @@ ZEND_API zend_function *zend_std_get_method(zend_object **obj_ptr, zend_string * * If we're not and __call() handler exists, invoke it, otherwise error out. */ scope = zend_get_executed_scope(); - if (fbc->common.scope != scope || zobj->ce != scope) { + if (fbc->common.scope != scope) { zend_function *updated_fbc = zend_get_parent_private(scope, zobj->ce, lc_method_name); if (EXPECTED(updated_fbc != NULL)) { fbc = updated_fbc; @@ -1280,7 +1276,6 @@ ZEND_API zend_function *zend_std_get_method(zend_object **obj_ptr, zend_string * if (zobj->ce->__call) { fbc = zend_get_user_call_function(zobj->ce, method_name); } else { - scope = zend_get_executed_scope(); zend_throw_error(NULL, "Call to %s method %s::%s() from context '%s'", zend_visibility_string(fbc->common.fn_flags), ZEND_FN_SCOPE_NAME(fbc), ZSTR_VAL(method_name), scope ? ZSTR_VAL(scope->name) : ""); fbc = NULL; }

« previous php.cvs (#103074) next »