Skip to content

Commit 4d8541d

Browse files
committed
Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3: Fixed bug #78747
2 parents 6aece7b + 7469953 commit 4d8541d

File tree

3 files changed

+41
-14
lines changed

3 files changed

+41
-14
lines changed

ext/opcache/Optimizer/zend_func_info.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1633,8 +1633,7 @@ uint32_t zend_get_func_info(const zend_call_info *call_info, const zend_ssa *ssa
16331633
zval *zv;
16341634
func_info_t *info;
16351635

1636-
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);
1637-
if (zv) {
1636+
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))) {
16381637
info = Z_PTR_P(zv);
16391638
if (UNEXPECTED(zend_optimizer_is_disabled_func(info->name, info->name_len))) {
16401639
ret = MAY_BE_NULL;
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
--TEST--
2+
Internal static methods should not be confused with global functions
3+
--SKIPIF--
4+
<?php
5+
if (!extension_loaded('zend-test')) die('skip requires zend-test');
6+
?>
7+
--FILE--
8+
<?php
9+
10+
var_dump(is_bool(_ZendTestClass::is_object()));
11+
12+
?>
13+
--EXPECT--
14+
bool(false)

ext/zend_test/test.c

Lines changed: 26 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -159,17 +159,20 @@ static zend_function *zend_test_class_method_get(zend_object **object, zend_stri
159159
/* }}} */
160160

161161
static zend_function *zend_test_class_static_method_get(zend_class_entry *ce, zend_string *name) /* {{{ */ {
162-
zend_internal_function *fptr = emalloc(sizeof(zend_internal_function));
163-
fptr->type = ZEND_OVERLOADED_FUNCTION;
164-
fptr->num_args = 1;
165-
fptr->arg_info = NULL;
166-
fptr->scope = ce;
167-
fptr->fn_flags = ZEND_ACC_CALL_VIA_HANDLER|ZEND_ACC_STATIC;
168-
fptr->function_name = name;
169-
fptr->handler = ZEND_FN(zend_test_func);
170-
zend_set_function_arg_flags((zend_function*)fptr);
171-
172-
return (zend_function*)fptr;
162+
if (zend_string_equals_literal_ci(name, "test")) {
163+
zend_internal_function *fptr = emalloc(sizeof(zend_internal_function));
164+
fptr->type = ZEND_OVERLOADED_FUNCTION;
165+
fptr->num_args = 1;
166+
fptr->arg_info = NULL;
167+
fptr->scope = ce;
168+
fptr->fn_flags = ZEND_ACC_CALL_VIA_HANDLER|ZEND_ACC_STATIC;
169+
fptr->function_name = name;
170+
fptr->handler = ZEND_FN(zend_test_func);
171+
zend_set_function_arg_flags((zend_function*)fptr);
172+
173+
return (zend_function*)fptr;
174+
}
175+
return zend_std_get_static_method(ce, name, NULL);
173176
}
174177
/* }}} */
175178

@@ -179,11 +182,22 @@ static int zend_test_class_call_method(zend_string *method, zend_object *object,
179182
}
180183
/* }}} */
181184

185+
/* Internal function returns bool, we return int. */
186+
static ZEND_METHOD(_ZendTestClass, is_object) /* {{{ */ {
187+
RETURN_LONG(42);
188+
}
189+
/* }}} */
190+
182191
static ZEND_METHOD(_ZendTestTrait, testMethod) /* {{{ */ {
183192
RETURN_TRUE;
184193
}
185194
/* }}} */
186195

196+
static const zend_function_entry zend_test_class_methods[] = {
197+
ZEND_ME(_ZendTestClass, is_object, NULL, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC)
198+
ZEND_FE_END
199+
};
200+
187201
static const zend_function_entry zend_test_trait_methods[] = {
188202
ZEND_ME(_ZendTestTrait, testMethod, NULL, ZEND_ACC_PUBLIC)
189203
ZEND_FE_END
@@ -196,7 +210,7 @@ PHP_MINIT_FUNCTION(zend_test)
196210
INIT_CLASS_ENTRY(class_entry, "_ZendTestInterface", NULL);
197211
zend_test_interface = zend_register_internal_interface(&class_entry);
198212
zend_declare_class_constant_long(zend_test_interface, ZEND_STRL("DUMMY"), 0);
199-
INIT_CLASS_ENTRY(class_entry, "_ZendTestClass", NULL);
213+
INIT_CLASS_ENTRY(class_entry, "_ZendTestClass", zend_test_class_methods);
200214
zend_test_class = zend_register_internal_class_ex(&class_entry, NULL);
201215
zend_class_implements(zend_test_class, 1, zend_test_interface);
202216
zend_test_class->create_object = zend_test_class_new;

0 commit comments

Comments
 (0)