Skip to content

Commit 4f8f5b2

Browse files
author
cpriest
committed
Changed IS_ACCESSOR() to IS_ACCESSOR_FN() macros, removed IS_ACCESSOR(), more concise code.
1 parent 076f220 commit 4f8f5b2

File tree

5 files changed

+13
-14
lines changed

5 files changed

+13
-14
lines changed

Zend/zend_compile.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3757,7 +3757,7 @@ static void do_inheritance_check_on_method(zend_function *child, zend_function *
37573757
}
37583758

37593759
if (parent_flags & ZEND_ACC_FINAL) {
3760-
if (IS_ACCESSOR(parent->common.purpose)) {
3760+
if (IS_ACCESSOR_FN(parent)) {
37613761
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));
37623762
} else {
37633763
zend_error(E_COMPILE_ERROR, "Cannot override final method %s::%s()", ZEND_FN_SCOPE_NAME(parent), child->common.function_name);
@@ -3769,13 +3769,13 @@ static void do_inheritance_check_on_method(zend_function *child, zend_function *
37693769
*/
37703770
if ((child_flags & ZEND_ACC_STATIC) != (parent_flags & ZEND_ACC_STATIC)) {
37713771
if (child->common.fn_flags & ZEND_ACC_STATIC) {
3772-
if(IS_ACCESSOR(child->common.purpose)) {
3772+
if(IS_ACCESSOR_FN(child)) {
37733773
zend_error(E_COMPILE_ERROR, "Cannot make non static accessor %s::$%s static in class %s", ZEND_FN_SCOPE_NAME(parent), ZEND_ACC_NAME(child), ZEND_FN_SCOPE_NAME(child));
37743774
} else {
37753775
zend_error(E_COMPILE_ERROR, "Cannot make non static method %s::%s() static in class %s", ZEND_FN_SCOPE_NAME(parent), child->common.function_name, ZEND_FN_SCOPE_NAME(child));
37763776
}
37773777
} else {
3778-
if(IS_ACCESSOR(child->common.purpose)) {
3778+
if(IS_ACCESSOR_FN(child)) {
37793779
zend_error(E_COMPILE_ERROR, "Cannot make static accessor %s::$%s non static in class %s", ZEND_FN_SCOPE_NAME(parent), ZEND_ACC_NAME(child), ZEND_FN_SCOPE_NAME(child));
37803780
} else {
37813781
zend_error(E_COMPILE_ERROR, "Cannot make static method %s::%s() non static in class %s", ZEND_FN_SCOPE_NAME(parent), child->common.function_name, ZEND_FN_SCOPE_NAME(child));
@@ -3794,7 +3794,7 @@ static void do_inheritance_check_on_method(zend_function *child, zend_function *
37943794
/* Prevent derived classes from restricting access that was available in parent classes
37953795
*/
37963796
if ((child_flags & ZEND_ACC_PPP_MASK) > (parent_flags & ZEND_ACC_PPP_MASK)) {
3797-
if (IS_ACCESSOR(child->common.purpose)) {
3797+
if (IS_ACCESSOR_FN(child)) {
37983798
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");
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");
@@ -3969,7 +3969,7 @@ static inline void zend_do_update_accessors(zend_class_entry *ce TSRMLS_DC) /* {
39693969
for (zend_hash_internal_pointer_reset(&ce->function_table);
39703970
zend_hash_get_current_data(&ce->function_table, (void *) &func) == SUCCESS;
39713971
zend_hash_move_forward(&ce->function_table)) {
3972-
if (IS_ACCESSOR(func->common.purpose)) {
3972+
if (IS_ACCESSOR_FN(func)) {
39733973
const char *varname = ZEND_ACC_NAME(func);
39743974
ulong hash_value = zend_hash_func(varname, strlen(varname)+1);
39753975

@@ -7638,7 +7638,7 @@ void zend_do_end_compilation(TSRMLS_D) /* {{{ */
76387638

76397639
const char *zend_get_accessor_name_from_function(const zend_function *func TSRMLS_DC) /* {{{ */
76407640
{
7641-
if(!func || !IS_ACCESSOR(func->common.purpose))
7641+
if(!func || !IS_ACCESSOR_FN(func))
76427642
return "Not an accessor";
76437643

76447644
switch(func->common.purpose) {
@@ -7682,7 +7682,7 @@ zend_accessor_info *zend_get_accessor_info_from_function(const zend_function *fu
76827682

76837683
zend_accessor_info **aipp;
76847684

7685-
if(!func || !IS_ACCESSOR(func->common.purpose))
7685+
if(!func || !IS_ACCESSOR_FN(func))
76867686
return NULL;
76877687

76887688
switch(func->common.purpose) {

Zend/zend_compile.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@
3535
#define FREE_PNODE(znode) zval_dtor(&znode->u.constant);
3636

3737
#define IS_ACCESSOR_FN(fn) ( fn->common.purpose >= ZEND_FNP_PROP_GETTER && fn->common.purpose <= ZEND_FNP_PROP_UNSETTER )
38-
#define IS_ACCESSOR(purpose) ( purpose >= ZEND_FNP_PROP_GETTER && purpose <= ZEND_FNP_PROP_UNSETTER )
3938

4039
#define INIT_ZNODE(zn) \
4140
{ \

Zend/zend_execute_API.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1635,7 +1635,7 @@ typedef struct _zend_abstract_info {
16351635
static int zend_verify_abstract_class_function(zend_function *fn, zend_abstract_info *ai TSRMLS_DC) /* {{{ */
16361636
{
16371637
if (fn->common.fn_flags & ZEND_ACC_ABSTRACT) {
1638-
if(IS_ACCESSOR(fn->common.purpose)) {
1638+
if(IS_ACCESSOR_FN(fn)) {
16391639
if (ai->abs_acc_count < MAX_ABSTRACT_INFO_CNT) {
16401640
ai->abs_acc[ai->abs_acc_count] = fn;
16411641
}

Zend/zend_object_handlers.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1109,7 +1109,7 @@ static union _zend_function *zend_std_get_method(zval **object_ptr, char *method
11091109
if (zobj->ce->__call) {
11101110
fbc = zend_get_user_call_function(zobj->ce, method_name, method_len);
11111111
} else {
1112-
if(IS_ACCESSOR(fbc->op_array.purpose)) {
1112+
if(IS_ACCESSOR_FN(fbc)) {
11131113
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 : "");
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 : "");
@@ -1139,7 +1139,7 @@ static union _zend_function *zend_std_get_method(zval **object_ptr, char *method
11391139
if (zobj->ce->__call) {
11401140
fbc = zend_get_user_call_function(zobj->ce, method_name, method_len);
11411141
} else {
1142-
if(IS_ACCESSOR(fbc->op_array.purpose)) {
1142+
if(IS_ACCESSOR_FN(fbc)) {
11431143
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 : "");
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 : "");
@@ -1284,7 +1284,7 @@ ZEND_API zend_function *zend_std_get_static_method(zend_class_entry *ce, const c
12841284
if (ce->__callstatic) {
12851285
fbc = zend_get_user_callstatic_function(ce, function_name_strval, function_name_strlen);
12861286
} else {
1287-
if(IS_ACCESSOR(fbc->op_array.purpose)) {
1287+
if(IS_ACCESSOR_FN(fbc)) {
12881288
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 : "");
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 : "");
@@ -1298,7 +1298,7 @@ ZEND_API zend_function *zend_std_get_static_method(zend_class_entry *ce, const c
12981298
if (ce->__callstatic) {
12991299
fbc = zend_get_user_callstatic_function(ce, function_name_strval, function_name_strlen);
13001300
} else {
1301-
if(IS_ACCESSOR(fbc->op_array.purpose)) {
1301+
if(IS_ACCESSOR_FN(fbc)) {
13021302
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 : "");
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 : "");

ext/reflection/php_reflection.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3830,7 +3830,7 @@ static void _addmethod(zend_function *mptr, zend_class_entry *ce, zval *retval,
38303830
uint len = strlen(mptr->common.function_name);
38313831
zend_function *closure;
38323832

3833-
if (mptr->common.fn_flags & filter && !(IS_ACCESSOR(mptr->common.purpose))) {
3833+
if (mptr->common.fn_flags & filter && !(IS_ACCESSOR_FN(mptr))) {
38343834
ALLOC_ZVAL(method);
38353835
if (ce == zend_ce_closure && obj && (len == sizeof(ZEND_INVOKE_FUNC_NAME)-1)
38363836
&& memcmp(mptr->common.function_name, ZEND_INVOKE_FUNC_NAME, sizeof(ZEND_INVOKE_FUNC_NAME)-1) == 0

0 commit comments

Comments
 (0)