Skip to content

Commit

Permalink
Eliminate useless $this related check
Browse files Browse the repository at this point in the history
  • Loading branch information
dstogov committed Nov 14, 2018
1 parent 5ebefa7 commit 8bda225
Show file tree
Hide file tree
Showing 7 changed files with 45 additions and 33 deletions.
24 changes: 16 additions & 8 deletions ext/date/php_date.c
Original file line number Diff line number Diff line change
Expand Up @@ -3269,7 +3269,8 @@ PHP_METHOD(DateTimeImmutable, modify)
char *modify;
size_t modify_len;

if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Os", &object, date_ce_immutable, &modify, &modify_len) == FAILURE) {
object = &EX(This);
if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &modify, &modify_len) == FAILURE) {
RETURN_FALSE;
}

Expand Down Expand Up @@ -3322,7 +3323,8 @@ PHP_METHOD(DateTimeImmutable, add)
{
zval *object, *interval, new_object;

if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "OO", &object, date_ce_immutable, &interval, date_ce_interval) == FAILURE) {
object = &EX(This);
if (zend_parse_parameters(ZEND_NUM_ARGS(), "O", &interval, date_ce_interval) == FAILURE) {
RETURN_FALSE;
}

Expand Down Expand Up @@ -3378,7 +3380,8 @@ PHP_METHOD(DateTimeImmutable, sub)
{
zval *object, *interval, new_object;

if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "OO", &object, date_ce_immutable, &interval, date_ce_interval) == FAILURE) {
object = &EX(This);
if (zend_parse_parameters(ZEND_NUM_ARGS(), "O", &interval, date_ce_interval) == FAILURE) {
RETURN_FALSE;
}

Expand Down Expand Up @@ -3482,7 +3485,8 @@ PHP_METHOD(DateTimeImmutable, setTimezone)
zval *object, new_object;
zval *timezone_object;

if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "OO", &object, date_ce_immutable, &timezone_object, date_ce_timezone) == FAILURE) {
object = &EX(This);
if (zend_parse_parameters(ZEND_NUM_ARGS(), "O", &timezone_object, date_ce_timezone) == FAILURE) {
RETURN_FALSE;
}

Expand Down Expand Up @@ -3567,7 +3571,8 @@ PHP_METHOD(DateTimeImmutable, setTime)
zval *object, new_object;
zend_long h, i, s = 0, ms = 0;

if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Oll|ll", &object, date_ce_immutable, &h, &i, &s, &ms) == FAILURE) {
object = &EX(This);
if (zend_parse_parameters(ZEND_NUM_ARGS(), "ll|ll", &h, &i, &s, &ms) == FAILURE) {
RETURN_FALSE;
}

Expand Down Expand Up @@ -3616,7 +3621,8 @@ PHP_METHOD(DateTimeImmutable, setDate)
zval *object, new_object;
zend_long y, m, d;

if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Olll", &object, date_ce_immutable, &y, &m, &d) == FAILURE) {
object = &EX(This);
if (zend_parse_parameters(ZEND_NUM_ARGS(), "lll", &y, &m, &d) == FAILURE) {
RETURN_FALSE;
}

Expand Down Expand Up @@ -3669,7 +3675,8 @@ PHP_METHOD(DateTimeImmutable, setISODate)
zval *object, new_object;
zend_long y, w, d = 1;

if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Oll|l", &object, date_ce_immutable, &y, &w, &d) == FAILURE) {
object = &EX(This);
if (zend_parse_parameters(ZEND_NUM_ARGS(), "ll|l", &y, &w, &d) == FAILURE) {
RETURN_FALSE;
}

Expand Down Expand Up @@ -3717,7 +3724,8 @@ PHP_METHOD(DateTimeImmutable, setTimestamp)
zval *object, new_object;
zend_long timestamp;

if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Ol", &object, date_ce_immutable, &timestamp) == FAILURE) {
object = &EX(This);
if (zend_parse_parameters(ZEND_NUM_ARGS(), "l", &timestamp) == FAILURE) {
RETURN_FALSE;
}

Expand Down
20 changes: 10 additions & 10 deletions ext/intl/breakiterator/breakiterator_methods.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ U_CFUNC PHP_FUNCTION(breakiter_create_code_point_instance)
U_CFUNC PHP_FUNCTION(breakiter_get_text)
{
BREAKITER_METHOD_INIT_VARS;
object = getThis();
object = &EX(This);

if (zend_parse_parameters_none() == FAILURE) {
intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR,
Expand All @@ -152,7 +152,7 @@ U_CFUNC PHP_FUNCTION(breakiter_set_text)
UText *ut = NULL;
zend_string *text;
BREAKITER_METHOD_INIT_VARS;
object = getThis();
object = &EX(This);

if (zend_parse_parameters(ZEND_NUM_ARGS(), "S", &text) == FAILURE) {
intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR,
Expand Down Expand Up @@ -186,7 +186,7 @@ static void _breakiter_no_args_ret_int32(
{
char *msg;
BREAKITER_METHOD_INIT_VARS;
object = getThis();
object = &EX(This);

if (zend_parse_parameters_none() == FAILURE) {
spprintf(&msg, 0, "%s: bad arguments", func_name);
Expand All @@ -210,7 +210,7 @@ static void _breakiter_int32_ret_int32(
char *msg;
zend_long arg;
BREAKITER_METHOD_INIT_VARS;
object = getThis();
object = &EX(This);

if (zend_parse_parameters(ZEND_NUM_ARGS(), "l", &arg) == FAILURE) {
spprintf(&msg, 0, "%s: bad arguments", func_name);
Expand Down Expand Up @@ -287,7 +287,7 @@ U_CFUNC PHP_FUNCTION(breakiter_next)
U_CFUNC PHP_FUNCTION(breakiter_current)
{
BREAKITER_METHOD_INIT_VARS;
object = getThis();
object = &EX(This);

if (zend_parse_parameters_none() == FAILURE) {
intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR,
Expand Down Expand Up @@ -320,7 +320,7 @@ U_CFUNC PHP_FUNCTION(breakiter_is_boundary)
{
zend_long offset;
BREAKITER_METHOD_INIT_VARS;
object = getThis();
object = &EX(This);

if (zend_parse_parameters(ZEND_NUM_ARGS(), "l",
&offset) == FAILURE) {
Expand All @@ -347,7 +347,7 @@ U_CFUNC PHP_FUNCTION(breakiter_get_locale)
{
zend_long locale_type;
BREAKITER_METHOD_INIT_VARS;
object = getThis();
object = &EX(This);

if (zend_parse_parameters(ZEND_NUM_ARGS(), "l", &locale_type) == FAILURE) {
intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR,
Expand Down Expand Up @@ -375,7 +375,7 @@ U_CFUNC PHP_FUNCTION(breakiter_get_parts_iterator)
{
zend_long key_type = 0;
BREAKITER_METHOD_INIT_VARS;
object = getThis();
object = &EX(This);

if (zend_parse_parameters(ZEND_NUM_ARGS(), "|l", &key_type) == FAILURE) {
intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR,
Expand All @@ -400,7 +400,7 @@ U_CFUNC PHP_FUNCTION(breakiter_get_parts_iterator)
U_CFUNC PHP_FUNCTION(breakiter_get_error_code)
{
BREAKITER_METHOD_INIT_VARS;
object = getThis();
object = &EX(This);

if (zend_parse_parameters_none() == FAILURE) {
intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR,
Expand All @@ -420,7 +420,7 @@ U_CFUNC PHP_FUNCTION(breakiter_get_error_message)
{
zend_string* message = NULL;
BREAKITER_METHOD_INIT_VARS;
object = getThis();
object = &EX(This);

if (zend_parse_parameters_none() == FAILURE) {
intl_error_set( NULL, U_ILLEGAL_ARGUMENT_ERROR,
Expand Down
2 changes: 1 addition & 1 deletion ext/intl/breakiterator/codepointiterator_methods.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ static inline CodePointBreakIterator *fetch_cpbi(BreakIterator_object *bio) {
U_CFUNC PHP_FUNCTION(cpbi_get_last_code_point)
{
BREAKITER_METHOD_INIT_VARS;
object = getThis();
object = &EX(This);

if (zend_parse_parameters_none() == FAILURE) {
intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR,
Expand Down
8 changes: 4 additions & 4 deletions ext/intl/breakiterator/rulebasedbreakiterator_methods.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ U_CFUNC PHP_METHOD(IntlRuleBasedBreakIterator, __construct)
U_CFUNC PHP_FUNCTION(rbbi_get_rules)
{
BREAKITER_METHOD_INIT_VARS;
object = getThis();
object = &EX(This);

if (zend_parse_parameters_none() == FAILURE) {
intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR,
Expand All @@ -129,7 +129,7 @@ U_CFUNC PHP_FUNCTION(rbbi_get_rules)
U_CFUNC PHP_FUNCTION(rbbi_get_rule_status)
{
BREAKITER_METHOD_INIT_VARS;
object = getThis();
object = &EX(This);

if (zend_parse_parameters_none() == FAILURE) {
intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR,
Expand All @@ -145,7 +145,7 @@ U_CFUNC PHP_FUNCTION(rbbi_get_rule_status)
U_CFUNC PHP_FUNCTION(rbbi_get_rule_status_vec)
{
BREAKITER_METHOD_INIT_VARS;
object = getThis();
object = &EX(This);

if (zend_parse_parameters_none() == FAILURE) {
intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR,
Expand Down Expand Up @@ -185,7 +185,7 @@ U_CFUNC PHP_FUNCTION(rbbi_get_rule_status_vec)
U_CFUNC PHP_FUNCTION(rbbi_get_binary_rules)
{
BREAKITER_METHOD_INIT_VARS;
object = getThis();
object = &EX(This);

if (zend_parse_parameters_none() == FAILURE) {
intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR,
Expand Down
20 changes: 12 additions & 8 deletions ext/intl/calendar/calendar_methods.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -409,23 +409,25 @@ U_CFUNC PHP_FUNCTION(intlcal_set)
int variant; /* number of args of the set() overload */
CALENDAR_METHOD_INIT_VARS;

object = getThis();

/* must come before zpp because zpp would convert the args in the stack to 0 */
if (ZEND_NUM_ARGS() > (getThis() ? 6 : 7) ||
if (ZEND_NUM_ARGS() > (object ? 6 : 7) ||
zend_get_parameters_array_ex(ZEND_NUM_ARGS(), args) == FAILURE) {
intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR,
"intlcal_set: too many arguments", 0);
RETURN_FALSE;
}
if (!getThis()) {
if (!object) {
args++;
}
variant = ZEND_NUM_ARGS() - (getThis() ? 0 : 1);
variant = ZEND_NUM_ARGS() - (object ? 0 : 1);
while (variant > 2 && Z_TYPE(args[variant - 1]) == IS_NULL) {
variant--;
}

if (variant == 4 ||
zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(),
zend_parse_method_parameters(ZEND_NUM_ARGS(), object,
"Oll|llll", &object, Calendar_ce_ptr, &arg1, &arg2, &arg3, &arg4,
&arg5, &arg6) == FAILURE) {
intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR,
Expand Down Expand Up @@ -472,25 +474,27 @@ U_CFUNC PHP_FUNCTION(intlcal_roll)
zend_bool bool_variant_val = (zend_bool)-1;
CALENDAR_METHOD_INIT_VARS;

if (ZEND_NUM_ARGS() > (getThis() ? 2 :3) ||
object = getThis();

if (ZEND_NUM_ARGS() > (object ? 2 :3) ||
zend_get_parameters_array_ex(ZEND_NUM_ARGS(), args) == FAILURE) {
intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR,
"intlcal_set: too many arguments", 0);
RETURN_FALSE;
}
if (!getThis()) {
if (!object) {
args++;
}
if (!Z_ISUNDEF(args[1]) && (Z_TYPE(args[1]) == IS_TRUE || Z_TYPE(args[1]) == IS_FALSE)) {
if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(),
if (zend_parse_method_parameters(ZEND_NUM_ARGS(), object,
"Olb", &object, Calendar_ce_ptr, &field, &bool_variant_val)
== FAILURE) {
intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR,
"intlcal_roll: bad arguments", 0);
RETURN_FALSE;
}
bool_variant_val = Z_TYPE(args[1]) == IS_TRUE? 1 : 0;
} else if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(),
} else if (zend_parse_method_parameters(ZEND_NUM_ARGS(), object,
"Oll", &object, Calendar_ce_ptr, &field, &value) == FAILURE) {
intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR,
"intlcal_roll: bad arguments", 0);
Expand Down
2 changes: 1 addition & 1 deletion ext/intl/common/common_enum.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ extern "C" {
#define INTLITERATOR_METHOD_INIT_VARS INTL_METHOD_INIT_VARS(IntlIterator, ii)
#define INTLITERATOR_METHOD_FETCH_OBJECT_NO_CHECK INTL_METHOD_FETCH_OBJECT(INTL_ITERATOR, ii)
#define INTLITERATOR_METHOD_FETCH_OBJECT\
object = getThis(); \
object = &EX(This); \
INTLITERATOR_METHOD_FETCH_OBJECT_NO_CHECK; \
if (ii->iterator == NULL) { \
intl_errors_set(&ii->err, U_ILLEGAL_ARGUMENT_ERROR, "Found unconstructed IntlIterator", 0); \
Expand Down
2 changes: 1 addition & 1 deletion ext/intl/spoofchecker/spoofchecker_class.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ extern zend_class_entry *Spoofchecker_ce_ptr;
/* Auxiliary macros */

#define SPOOFCHECKER_METHOD_INIT_VARS \
zval* object = getThis(); \
zval* object = &EX(This); \
Spoofchecker_object* co = NULL; \
intl_error_reset(NULL); \

Expand Down

0 comments on commit 8bda225

Please sign in to comment.