diff options
author | Nikita Popov <nikita.ppv@gmail.com> | 2019-10-25 12:50:26 +0200 |
---|---|---|
committer | Nikita Popov <nikita.ppv@gmail.com> | 2019-10-25 12:50:26 +0200 |
commit | 4d8541debbc4f2387879a872b42604ed8b908f58 (patch) | |
tree | e37bed2c6bd806a40b56a47597e75be934f94b6f | |
parent | 6aece7be0a183affa2ad293adde3a9ed041331dd (diff) | |
parent | 74699533e54a2b2e6093834652138b6d3a71e5b8 (diff) | |
download | php-git-4d8541debbc4f2387879a872b42604ed8b908f58.tar.gz |
Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3:
Fixed bug #78747
-rw-r--r-- | ext/opcache/Optimizer/zend_func_info.c | 3 | ||||
-rw-r--r-- | ext/opcache/tests/internal_func_info_static_method.phpt | 14 | ||||
-rw-r--r-- | ext/zend_test/test.c | 38 |
3 files changed, 41 insertions, 14 deletions
diff --git a/ext/opcache/Optimizer/zend_func_info.c b/ext/opcache/Optimizer/zend_func_info.c index d9ff58e75e..5c7a30a9f5 100644 --- a/ext/opcache/Optimizer/zend_func_info.c +++ b/ext/opcache/Optimizer/zend_func_info.c @@ -1633,8 +1633,7 @@ uint32_t zend_get_func_info(const zend_call_info *call_info, const zend_ssa *ssa zval *zv; func_info_t *info; - zv = zend_hash_find_ex(&func_info, Z_STR_P(CRT_CONSTANT_EX(call_info->caller_op_array, call_info->caller_init_opline, call_info->caller_init_opline->op2, ssa->rt_constants)), 1); - if (zv) { + if (!call_info->callee_func->common.scope && (zv = zend_hash_find_ex(&func_info, Z_STR_P(CRT_CONSTANT_EX(call_info->caller_op_array, call_info->caller_init_opline, call_info->caller_init_opline->op2, ssa->rt_constants)), 1))) { info = Z_PTR_P(zv); if (UNEXPECTED(zend_optimizer_is_disabled_func(info->name, info->name_len))) { ret = MAY_BE_NULL; diff --git a/ext/opcache/tests/internal_func_info_static_method.phpt b/ext/opcache/tests/internal_func_info_static_method.phpt new file mode 100644 index 0000000000..df4e9b2aab --- /dev/null +++ b/ext/opcache/tests/internal_func_info_static_method.phpt @@ -0,0 +1,14 @@ +--TEST-- +Internal static methods should not be confused with global functions +--SKIPIF-- +<?php +if (!extension_loaded('zend-test')) die('skip requires zend-test'); +?> +--FILE-- +<?php + +var_dump(is_bool(_ZendTestClass::is_object())); + +?> +--EXPECT-- +bool(false) diff --git a/ext/zend_test/test.c b/ext/zend_test/test.c index 53af862d24..ad5f2fb446 100644 --- a/ext/zend_test/test.c +++ b/ext/zend_test/test.c @@ -159,17 +159,20 @@ static zend_function *zend_test_class_method_get(zend_object **object, zend_stri /* }}} */ static zend_function *zend_test_class_static_method_get(zend_class_entry *ce, zend_string *name) /* {{{ */ { - zend_internal_function *fptr = emalloc(sizeof(zend_internal_function)); - fptr->type = ZEND_OVERLOADED_FUNCTION; - fptr->num_args = 1; - fptr->arg_info = NULL; - fptr->scope = ce; - fptr->fn_flags = ZEND_ACC_CALL_VIA_HANDLER|ZEND_ACC_STATIC; - fptr->function_name = name; - fptr->handler = ZEND_FN(zend_test_func); - zend_set_function_arg_flags((zend_function*)fptr); - - return (zend_function*)fptr; + if (zend_string_equals_literal_ci(name, "test")) { + zend_internal_function *fptr = emalloc(sizeof(zend_internal_function)); + fptr->type = ZEND_OVERLOADED_FUNCTION; + fptr->num_args = 1; + fptr->arg_info = NULL; + fptr->scope = ce; + fptr->fn_flags = ZEND_ACC_CALL_VIA_HANDLER|ZEND_ACC_STATIC; + fptr->function_name = name; + fptr->handler = ZEND_FN(zend_test_func); + zend_set_function_arg_flags((zend_function*)fptr); + + return (zend_function*)fptr; + } + return zend_std_get_static_method(ce, name, NULL); } /* }}} */ @@ -179,11 +182,22 @@ static int zend_test_class_call_method(zend_string *method, zend_object *object, } /* }}} */ +/* Internal function returns bool, we return int. */ +static ZEND_METHOD(_ZendTestClass, is_object) /* {{{ */ { + RETURN_LONG(42); +} +/* }}} */ + static ZEND_METHOD(_ZendTestTrait, testMethod) /* {{{ */ { RETURN_TRUE; } /* }}} */ +static const zend_function_entry zend_test_class_methods[] = { + ZEND_ME(_ZendTestClass, is_object, NULL, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC) + ZEND_FE_END +}; + static const zend_function_entry zend_test_trait_methods[] = { ZEND_ME(_ZendTestTrait, testMethod, NULL, ZEND_ACC_PUBLIC) ZEND_FE_END @@ -196,7 +210,7 @@ PHP_MINIT_FUNCTION(zend_test) INIT_CLASS_ENTRY(class_entry, "_ZendTestInterface", NULL); zend_test_interface = zend_register_internal_interface(&class_entry); zend_declare_class_constant_long(zend_test_interface, ZEND_STRL("DUMMY"), 0); - INIT_CLASS_ENTRY(class_entry, "_ZendTestClass", NULL); + INIT_CLASS_ENTRY(class_entry, "_ZendTestClass", zend_test_class_methods); zend_test_class = zend_register_internal_class_ex(&class_entry, NULL); zend_class_implements(zend_test_class, 1, zend_test_interface); zend_test_class->create_object = zend_test_class_new; |