Skip to content

Commit 7d056fc

Browse files
committed
Merge branch 'PHP-7.4'
* PHP-7.4: Fixed bug #78747
2 parents 225a02f + 4d8541d commit 7d056fc

File tree

3 files changed

+41
-17
lines changed

3 files changed

+41
-17
lines changed

ext/opcache/Optimizer/zend_func_info.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -1224,8 +1224,8 @@ uint32_t zend_get_func_info(const zend_call_info *call_info, const zend_ssa *ssa
12241224
zval *zv;
12251225
zend_string *lcname = Z_STR_P(CRT_CONSTANT_EX(call_info->caller_op_array, call_info->caller_init_opline, call_info->caller_init_opline->op2));
12261226

1227-
zv = zend_hash_find_ex(&func_info, lcname, 1);
1228-
if (zv) {
1227+
if (!call_info->callee_func->common.scope
1228+
&& (zv = zend_hash_find_ex(&func_info, lcname, 1))) {
12291229
func_info_t *info = Z_PTR_P(zv);
12301230
if (UNEXPECTED(zend_optimizer_is_disabled_func(info->name, info->name_len))) {
12311231
ret = MAY_BE_NULL;
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

+25-15
Original file line numberDiff line numberDiff line change
@@ -168,22 +168,25 @@ static zend_function *zend_test_class_method_get(zend_object **object, zend_stri
168168
/* }}} */
169169

170170
static zend_function *zend_test_class_static_method_get(zend_class_entry *ce, zend_string *name) /* {{{ */ {
171-
zend_internal_function *fptr;
172-
173-
if (EXPECTED(EG(trampoline).common.function_name == NULL)) {
174-
fptr = (zend_internal_function *) &EG(trampoline);
175-
} else {
176-
fptr = emalloc(sizeof(zend_internal_function));
171+
if (zend_string_equals_literal_ci(name, "test")) {
172+
zend_internal_function *fptr;
173+
174+
if (EXPECTED(EG(trampoline).common.function_name == NULL)) {
175+
fptr = (zend_internal_function *) &EG(trampoline);
176+
} else {
177+
fptr = emalloc(sizeof(zend_internal_function));
178+
}
179+
memset(fptr, 0, sizeof(zend_internal_function));
180+
fptr->type = ZEND_INTERNAL_FUNCTION;
181+
fptr->num_args = 1;
182+
fptr->scope = ce;
183+
fptr->fn_flags = ZEND_ACC_CALL_VIA_HANDLER|ZEND_ACC_STATIC;
184+
fptr->function_name = zend_string_copy(name);
185+
fptr->handler = ZEND_FN(zend_test_func);
186+
187+
return (zend_function*)fptr;
177188
}
178-
memset(fptr, 0, sizeof(zend_internal_function));
179-
fptr->type = ZEND_INTERNAL_FUNCTION;
180-
fptr->num_args = 1;
181-
fptr->scope = ce;
182-
fptr->fn_flags = ZEND_ACC_CALL_VIA_HANDLER|ZEND_ACC_STATIC;
183-
fptr->function_name = zend_string_copy(name);
184-
fptr->handler = ZEND_FN(zend_test_func);
185-
186-
return (zend_function*)fptr;
189+
return zend_std_get_static_method(ce, name, NULL);
187190
}
188191
/* }}} */
189192

@@ -192,12 +195,19 @@ static ZEND_METHOD(_ZendTestClass, __toString) /* {{{ */ {
192195
}
193196
/* }}} */
194197

198+
/* Internal function returns bool, we return int. */
199+
static ZEND_METHOD(_ZendTestClass, is_object) /* {{{ */ {
200+
RETURN_LONG(42);
201+
}
202+
/* }}} */
203+
195204
static ZEND_METHOD(_ZendTestTrait, testMethod) /* {{{ */ {
196205
RETURN_TRUE;
197206
}
198207
/* }}} */
199208

200209
static const zend_function_entry zend_test_class_methods[] = {
210+
ZEND_ME(_ZendTestClass, is_object, NULL, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC)
201211
ZEND_ME(_ZendTestClass, __toString, NULL, ZEND_ACC_DEPRECATED)
202212
ZEND_FE_END
203213
};

0 commit comments

Comments
 (0)