Skip to content

Commit ee7d02d

Browse files
committed
zend_builtin_functions.c: use RET{URN|VAL}_BOOL() when possible
1 parent afd04af commit ee7d02d

File tree

1 file changed

+7
-20
lines changed

1 file changed

+7
-20
lines changed

Zend/zend_builtin_functions.c

Lines changed: 7 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -590,11 +590,7 @@ ZEND_FUNCTION(define)
590590
/* non persistent */
591591
ZEND_CONSTANT_SET_FLAGS(&c, 0, PHP_USER_CONSTANT);
592592
c.name = zend_string_copy(name);
593-
if (zend_register_constant(&c) != NULL) {
594-
RETURN_TRUE;
595-
} else {
596-
RETURN_FALSE;
597-
}
593+
RETURN_BOOL(zend_register_constant(&c) != NULL);
598594
}
599595
/* }}} */
600596

@@ -608,11 +604,7 @@ ZEND_FUNCTION(defined)
608604
Z_PARAM_STR(name)
609605
ZEND_PARSE_PARAMETERS_END();
610606

611-
if (zend_get_constant_ex(name, zend_get_executed_scope(), ZEND_FETCH_CLASS_SILENT)) {
612-
RETURN_TRUE;
613-
} else {
614-
RETURN_FALSE;
615-
}
607+
RETURN_BOOL(zend_get_constant_ex(name, zend_get_executed_scope(), ZEND_FETCH_CLASS_SILENT));
616608
}
617609
/* }}} */
618610

@@ -1043,11 +1035,10 @@ static void _property_exists(zval *return_value, const zval *object, zend_string
10431035
RETURN_TRUE;
10441036
}
10451037

1046-
if (Z_TYPE_P(object) == IS_OBJECT &&
1047-
Z_OBJ_HANDLER_P(object, has_property)(Z_OBJ_P(object), property, ZEND_PROPERTY_EXISTS, NULL)) {
1048-
RETURN_TRUE;
1049-
}
1050-
RETURN_FALSE;
1038+
RETURN_BOOL(
1039+
Z_TYPE_P(object) == IS_OBJECT &&
1040+
Z_OBJ_HANDLER_P(object, has_property)(Z_OBJ_P(object), property, ZEND_PROPERTY_EXISTS, NULL)
1041+
);
10511042
}
10521043

10531044
/* {{{ Checks if the object or class has a property */
@@ -1107,11 +1098,7 @@ static zend_always_inline void _class_exists_impl(zval *return_value, zend_strin
11071098
ce = zend_lookup_class(name);
11081099
}
11091100

1110-
if (ce) {
1111-
RETURN_BOOL(((ce->ce_flags & flags) == flags) && !(ce->ce_flags & skip_flags));
1112-
} else {
1113-
RETURN_FALSE;
1114-
}
1101+
RETURN_BOOL(ce && ((ce->ce_flags & flags) == flags) && !(ce->ce_flags & skip_flags));
11151102
}
11161103
/* {{{ */
11171104

0 commit comments

Comments
 (0)