Skip to content

Commit 20822c5

Browse files
author
cpriest
committed
Changed zend_fn_purpose_string() to accept a function rather than the purpose, cleans up some un-necessary dereferencing.
1 parent 4f8f5b2 commit 20822c5

File tree

4 files changed

+15
-16
lines changed

4 files changed

+15
-16
lines changed

Zend/zend_compile.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1855,7 +1855,7 @@ void zend_do_end_accessor_declaration(znode *function_token, znode *var_name, zn
18551855
efree(int_var_name);
18561856
CG(compiler_options) = original_compiler_options;
18571857
} else if(body != NULL && (CG(active_class_entry)->ce_flags & ZEND_ACC_INTERFACE) == ZEND_ACC_INTERFACE) {
1858-
zend_error(E_WARNING, "Interface %s::$%s %ster cannot have implementation defined, implementation ignored.", CG(active_class_entry)->name, Z_STRVAL(var_name->u.constant), zend_fn_purpose_string(CG(active_op_array)->purpose));
1858+
zend_error(E_WARNING, "Interface %s::$%s %ster cannot have implementation defined, implementation ignored.", CG(active_class_entry)->name, Z_STRVAL(var_name->u.constant), zend_fn_purpose_string(CG(active_op_array)));
18591859
}
18601860

18611861
zend_do_end_function_declaration(function_token TSRMLS_CC);
@@ -3425,15 +3425,15 @@ char *zend_visibility_string(zend_uint fn_flags) /* {{{ */
34253425
}
34263426
/* }}} */
34273427

3428-
char *zend_fn_purpose_string(zend_uchar purpose) /* {{{ */
3428+
char *zend_fn_purpose_string(zend_function *function) /* {{{ */
34293429
{
3430-
if (purpose == ZEND_FNP_PROP_GETTER) {
3430+
if (function->common.purpose == ZEND_FNP_PROP_GETTER) {
34313431
return "get";
3432-
} else if (purpose == ZEND_FNP_PROP_SETTER) {
3432+
} else if (function->common.purpose == ZEND_FNP_PROP_SETTER) {
34333433
return "set";
3434-
} else if (purpose == ZEND_FNP_PROP_ISSETTER) {
3434+
} else if (function->common.purpose == ZEND_FNP_PROP_ISSETTER) {
34353435
return "isset";
3436-
} else if (purpose == ZEND_FNP_PROP_UNSETTER) {
3436+
} else if (function->common.purpose == ZEND_FNP_PROP_UNSETTER) {
34373437
return "unset";
34383438
}
34393439
return "access";
@@ -3758,7 +3758,7 @@ static void do_inheritance_check_on_method(zend_function *child, zend_function *
37583758

37593759
if (parent_flags & ZEND_ACC_FINAL) {
37603760
if (IS_ACCESSOR_FN(parent)) {
3761-
zend_error(E_COMPILE_ERROR, "Cannot override final property %ster %s::$%s", zend_fn_purpose_string(child->common.purpose), ZEND_FN_SCOPE_NAME(parent), ZEND_ACC_NAME(child));
3761+
zend_error(E_COMPILE_ERROR, "Cannot override final property %ster %s::$%s", zend_fn_purpose_string(child), ZEND_FN_SCOPE_NAME(parent), ZEND_ACC_NAME(child));
37623762
} else {
37633763
zend_error(E_COMPILE_ERROR, "Cannot override final method %s::%s()", ZEND_FN_SCOPE_NAME(parent), child->common.function_name);
37643764
}
@@ -3795,7 +3795,7 @@ static void do_inheritance_check_on_method(zend_function *child, zend_function *
37953795
*/
37963796
if ((child_flags & ZEND_ACC_PPP_MASK) > (parent_flags & ZEND_ACC_PPP_MASK)) {
37973797
if (IS_ACCESSOR_FN(child)) {
3798-
zend_error(E_COMPILE_ERROR, "Access level to %ster %s::$%s must be %s (as in class %s)%s", zend_fn_purpose_string(child->common.purpose), ZEND_FN_SCOPE_NAME(child), ZEND_ACC_NAME(child), zend_visibility_string(parent_flags), ZEND_FN_SCOPE_NAME(parent), (parent_flags&ZEND_ACC_PUBLIC) ? "" : " or weaker");
3798+
zend_error(E_COMPILE_ERROR, "Access level to %ster %s::$%s must be %s (as in class %s)%s", zend_fn_purpose_string(child), ZEND_FN_SCOPE_NAME(child), ZEND_ACC_NAME(child), zend_visibility_string(parent_flags), ZEND_FN_SCOPE_NAME(parent), (parent_flags&ZEND_ACC_PUBLIC) ? "" : " or weaker");
37993799
} else {
38003800
zend_error(E_COMPILE_ERROR, "Access level to %s::%s() must be %s (as in class %s)%s", ZEND_FN_SCOPE_NAME(child), child->common.function_name, zend_visibility_string(parent_flags), ZEND_FN_SCOPE_NAME(parent), (parent_flags&ZEND_ACC_PUBLIC) ? "" : " or weaker");
38013801
}

Zend/zend_compile.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -245,9 +245,6 @@ typedef struct _zend_try_catch_element {
245245
#define ZEND_FNP_PROP_ISSETTER 3 /* Special purpose accessor: issetter */
246246
#define ZEND_FNP_PROP_UNSETTER 4 /* Special purpose accessor: unsetter */
247247

248-
char *zend_visibility_string(zend_uint fn_flags);
249-
char *zend_fn_purpose_string(zend_uchar purpose);
250-
251248

252249
typedef struct _zend_property_info {
253250
zend_uint flags;
@@ -701,6 +698,8 @@ const char *zend_get_accessor_name_from_function(const zend_function *func TSRML
701698
const char *zend_get_accessor_name_from_accessor_info(const zend_accessor_info *ai TSRMLS_DC);
702699
zend_accessor_info *zend_get_accessor_info_from_function(const zend_function *func TSRMLS_DC);
703700
zend_accessor_info *zend_get_accessor_from_init_static_method_call(zend_op_array *op_array, zend_op *opline, const char **context_name_out TSRMLS_DC);
701+
char *zend_visibility_string(zend_uint fn_flags);
702+
char *zend_fn_purpose_string(zend_function *function);
704703

705704

706705
ZEND_API void function_add_ref(zend_function *function);

Zend/zend_execute_API.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1615,7 +1615,7 @@ zend_class_entry *zend_fetch_class_by_name(const char *class_name, uint class_na
16151615
ai.afn[idx] && ai.afn[idx + 1] ? ", " : (ai.afn[idx] && ai.afn_cnt > MAX_ABSTRACT_INFO_CNT ? ", ..." : "")
16161616

16171617
#define DISPLAY_ABS_ACCESSOR_FN(idx) \
1618-
ai.abs_acc[idx] ? zend_fn_purpose_string(ai.abs_acc[idx]->common.purpose) : "", \
1618+
ai.abs_acc[idx] ? zend_fn_purpose_string(ai.abs_acc[idx]) : "", \
16191619
ai.abs_acc[idx] ? " " : "", \
16201620
ai.abs_acc[idx] ? ZEND_FN_SCOPE_NAME(ai.abs_acc[idx]) : "", \
16211621
ai.abs_acc[idx] ? "::$" : "", \

Zend/zend_object_handlers.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1110,7 +1110,7 @@ static union _zend_function *zend_std_get_method(zval **object_ptr, char *method
11101110
fbc = zend_get_user_call_function(zobj->ce, method_name, method_len);
11111111
} else {
11121112
if(IS_ACCESSOR_FN(fbc)) {
1113-
zend_error_noreturn(E_ERROR, "Cannot %s %s property %s::$%s from context '%s'", zend_fn_purpose_string(fbc->op_array.purpose), zend_visibility_string(fbc->common.fn_flags), ZEND_FN_SCOPE_NAME(fbc), ZEND_ACC_NAME(fbc), EG(scope) ? EG(scope)->name : "");
1113+
zend_error_noreturn(E_ERROR, "Cannot %s %s property %s::$%s from context '%s'", zend_fn_purpose_string(fbc), zend_visibility_string(fbc->common.fn_flags), ZEND_FN_SCOPE_NAME(fbc), ZEND_ACC_NAME(fbc), EG(scope) ? EG(scope)->name : "");
11141114
} else {
11151115
zend_error_noreturn(E_ERROR, "Call to %s method %s::%s() from context '%s'", zend_visibility_string(fbc->common.fn_flags), ZEND_FN_SCOPE_NAME(fbc), method_name, EG(scope) ? EG(scope)->name : "");
11161116
}
@@ -1140,7 +1140,7 @@ static union _zend_function *zend_std_get_method(zval **object_ptr, char *method
11401140
fbc = zend_get_user_call_function(zobj->ce, method_name, method_len);
11411141
} else {
11421142
if(IS_ACCESSOR_FN(fbc)) {
1143-
zend_error_noreturn(E_ERROR, "Cannot %s %s property %s::$%s from context '%s'", zend_fn_purpose_string(fbc->common.purpose), zend_visibility_string(fbc->common.fn_flags), ZEND_FN_SCOPE_NAME(fbc), ZEND_ACC_NAME(fbc), EG(scope) ? EG(scope)->name : "");
1143+
zend_error_noreturn(E_ERROR, "Cannot %s %s property %s::$%s from context '%s'", zend_fn_purpose_string(fbc), zend_visibility_string(fbc->common.fn_flags), ZEND_FN_SCOPE_NAME(fbc), ZEND_ACC_NAME(fbc), EG(scope) ? EG(scope)->name : "");
11441144
} else {
11451145
zend_error_noreturn(E_ERROR, "Call to %s method %s::%s() from context '%s'", zend_visibility_string(fbc->common.fn_flags), ZEND_FN_SCOPE_NAME(fbc), method_name, EG(scope) ? EG(scope)->name : "");
11461146
}
@@ -1285,7 +1285,7 @@ ZEND_API zend_function *zend_std_get_static_method(zend_class_entry *ce, const c
12851285
fbc = zend_get_user_callstatic_function(ce, function_name_strval, function_name_strlen);
12861286
} else {
12871287
if(IS_ACCESSOR_FN(fbc)) {
1288-
zend_error_noreturn(E_ERROR, "Cannot %s %s property %s::$%s from context '%s'", zend_fn_purpose_string(fbc->common.purpose), zend_visibility_string(fbc->common.fn_flags), ZEND_FN_SCOPE_NAME(fbc), ZEND_ACC_NAME(fbc), EG(scope) ? EG(scope)->name : "");
1288+
zend_error_noreturn(E_ERROR, "Cannot %s %s property %s::$%s from context '%s'", zend_fn_purpose_string(fbc), zend_visibility_string(fbc->common.fn_flags), ZEND_FN_SCOPE_NAME(fbc), ZEND_ACC_NAME(fbc), EG(scope) ? EG(scope)->name : "");
12891289
} else {
12901290
zend_error_noreturn(E_ERROR, "Call to %s method %s::%s() from context '%s'", zend_visibility_string(fbc->common.fn_flags), ZEND_FN_SCOPE_NAME(fbc), function_name_strval, EG(scope) ? EG(scope)->name : "");
12911291
}
@@ -1299,7 +1299,7 @@ ZEND_API zend_function *zend_std_get_static_method(zend_class_entry *ce, const c
12991299
fbc = zend_get_user_callstatic_function(ce, function_name_strval, function_name_strlen);
13001300
} else {
13011301
if(IS_ACCESSOR_FN(fbc)) {
1302-
zend_error_noreturn(E_ERROR, "Cannot %s %s property %s::$%s from context '%s'", zend_fn_purpose_string(fbc->common.purpose), zend_visibility_string(fbc->common.fn_flags), ZEND_FN_SCOPE_NAME(fbc), ZEND_ACC_NAME(fbc), EG(scope) ? EG(scope)->name : "");
1302+
zend_error_noreturn(E_ERROR, "Cannot %s %s property %s::$%s from context '%s'", zend_fn_purpose_string(fbc), zend_visibility_string(fbc->common.fn_flags), ZEND_FN_SCOPE_NAME(fbc), ZEND_ACC_NAME(fbc), EG(scope) ? EG(scope)->name : "");
13031303
} else {
13041304
zend_error_noreturn(E_ERROR, "Call to %s method %s::%s() from context '%s'", zend_visibility_string(fbc->common.fn_flags), ZEND_FN_SCOPE_NAME(fbc), function_name_strval, EG(scope) ? EG(scope)->name : "");
13051305
}

0 commit comments

Comments
 (0)