Merge branch 'PHP-7.4'

This commit is contained in:
Nikita Popov 2019-09-03 13:59:59 +02:00
commit cc4af3513d
4 changed files with 17 additions and 15 deletions

View file

@ -40,7 +40,7 @@ var_dump($example->propertyBarExists());
?> ?>
--EXPECT-- --EXPECT--
bool(true) bool(false)
bool(true) bool(true)
bool(true) bool(true)
bool(true) bool(true)

View file

@ -62,7 +62,7 @@ bool(true)
bool(true) bool(true)
---- ----
bool(true) bool(true)
bool(true) bool(false)
bool(true) bool(true)
---- ----
bool(true) bool(true)

View file

@ -1125,7 +1125,8 @@ ZEND_FUNCTION(method_exists)
zval *klass; zval *klass;
zend_string *method_name; zend_string *method_name;
zend_string *lcname; zend_string *lcname;
zend_class_entry * ce; zend_class_entry *ce;
zend_function *func;
ZEND_PARSE_PARAMETERS_START(2, 2) ZEND_PARSE_PARAMETERS_START(2, 2)
Z_PARAM_ZVAL(klass) Z_PARAM_ZVAL(klass)
@ -1143,28 +1144,29 @@ ZEND_FUNCTION(method_exists)
} }
lcname = zend_string_tolower(method_name); lcname = zend_string_tolower(method_name);
if (zend_hash_exists(&ce->function_table, lcname)) { func = zend_hash_find_ptr(&ce->function_table, lcname);
zend_string_release_ex(lcname, 0); zend_string_release_ex(lcname, 0);
RETURN_TRUE;
} else if (Z_TYPE_P(klass) == IS_OBJECT) { if (func) {
RETURN_BOOL(!(func->common.fn_flags & ZEND_ACC_PRIVATE) || func->common.scope == ce);
}
if (Z_TYPE_P(klass) == IS_OBJECT) {
zend_object *obj = Z_OBJ_P(klass); zend_object *obj = Z_OBJ_P(klass);
zend_function *func = Z_OBJ_HT_P(klass)->get_method(&obj, method_name, NULL); func = Z_OBJ_HT_P(klass)->get_method(&obj, method_name, NULL);
if (func != NULL) { if (func != NULL) {
if (func->common.fn_flags & ZEND_ACC_CALL_VIA_TRAMPOLINE) { if (func->common.fn_flags & ZEND_ACC_CALL_VIA_TRAMPOLINE) {
/* Returns true to the fake Closure's __invoke */ /* Returns true to the fake Closure's __invoke */
RETVAL_BOOL(func->common.scope == zend_ce_closure RETVAL_BOOL(func->common.scope == zend_ce_closure
&& zend_string_equals_literal(method_name, ZEND_INVOKE_FUNC_NAME)); && zend_string_equals_literal(method_name, ZEND_INVOKE_FUNC_NAME));
zend_string_release_ex(lcname, 0);
zend_string_release_ex(func->common.function_name, 0); zend_string_release_ex(func->common.function_name, 0);
zend_free_trampoline(func); zend_free_trampoline(func);
return; return;
} }
zend_string_release_ex(lcname, 0);
RETURN_TRUE; RETURN_TRUE;
} }
} }
zend_string_release_ex(lcname, 0);
RETURN_FALSE; RETURN_FALSE;
} }
/* }}} */ /* }}} */

View file

@ -53,10 +53,10 @@ echo "Done";
---(Using string class name)--- ---(Using string class name)---
Does C::inherit_pub exist? bool(true) Does C::inherit_pub exist? bool(true)
Does C::inherit_prot exist? bool(true) Does C::inherit_prot exist? bool(true)
Does C::inherit_priv exist? bool(true) Does C::inherit_priv exist? bool(false)
Does C::inherit_static_pub exist? bool(true) Does C::inherit_static_pub exist? bool(true)
Does C::inherit_static_prot exist? bool(true) Does C::inherit_static_prot exist? bool(true)
Does C::inherit_static_priv exist? bool(true) Does C::inherit_static_priv exist? bool(false)
Does C::pub exist? bool(true) Does C::pub exist? bool(true)
Does C::prot exist? bool(true) Does C::prot exist? bool(true)
Does C::priv exist? bool(true) Does C::priv exist? bool(true)
@ -68,10 +68,10 @@ Does C::non_existent exist? bool(false)
---(Using object)--- ---(Using object)---
Does C::inherit_pub exist? bool(true) Does C::inherit_pub exist? bool(true)
Does C::inherit_prot exist? bool(true) Does C::inherit_prot exist? bool(true)
Does C::inherit_priv exist? bool(true) Does C::inherit_priv exist? bool(false)
Does C::inherit_static_pub exist? bool(true) Does C::inherit_static_pub exist? bool(true)
Does C::inherit_static_prot exist? bool(true) Does C::inherit_static_prot exist? bool(true)
Does C::inherit_static_priv exist? bool(true) Does C::inherit_static_priv exist? bool(false)
Does C::pub exist? bool(true) Does C::pub exist? bool(true)
Does C::prot exist? bool(true) Does C::prot exist? bool(true)
Does C::priv exist? bool(true) Does C::priv exist? bool(true)