summaryrefslogtreecommitdiff
path: root/Zend/zend_compile.c
diff options
context:
space:
mode:
authorDmitry Stogov <dmitry@zend.com>2018-07-02 17:03:02 +0300
committerDmitry Stogov <dmitry@zend.com>2018-07-02 17:03:02 +0300
commit43aca3118ab011b878ec577904eafc18f86f69ae (patch)
tree96ea9c20bebffe97ab9dcea311c681845aef6a9b /Zend/zend_compile.c
parenta63e834b66046d507c8f67de3c9a7251c4e327f4 (diff)
downloadphp-git-43aca3118ab011b878ec577904eafc18f86f69ae.tar.gz
Avoid string comparisons for magic methods (all magic methods start with "__")
Diffstat (limited to 'Zend/zend_compile.c')
-rw-r--r--Zend/zend_compile.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c
index 310fac9cc9..46fb089862 100644
--- a/Zend/zend_compile.c
+++ b/Zend/zend_compile.c
@@ -5772,7 +5772,9 @@ void zend_begin_method_decl(zend_op_array *op_array, zend_string *name, zend_boo
}
if (in_interface) {
- if (zend_string_equals_literal(lcname, ZEND_CALL_FUNC_NAME)) {
+ if (ZSTR_VAL(lcname)[0] != '_' || ZSTR_VAL(lcname)[1] != '_') {
+ /* pass */
+ } else if (zend_string_equals_literal(lcname, ZEND_CALL_FUNC_NAME)) {
if (!is_public || is_static) {
zend_error(E_WARNING, "The magic method __call() must have "
"public visibility and cannot be static");
@@ -5823,6 +5825,10 @@ void zend_begin_method_decl(zend_op_array *op_array, zend_string *name, zend_boo
if (!ce->constructor) {
ce->constructor = (zend_function *) op_array;
}
+ } else if (ZSTR_VAL(lcname)[0] != '_' || ZSTR_VAL(lcname)[1] != '_') {
+ if (!is_static) {
+ op_array->fn_flags |= ZEND_ACC_ALLOW_STATIC;
+ }
} else if (zend_string_equals_literal(lcname, ZEND_CONSTRUCTOR_FUNC_NAME)) {
ce->constructor = (zend_function *) op_array;
} else if (zend_string_equals_literal(lcname, ZEND_DESTRUCTOR_FUNC_NAME)) {