Skip to content

Commit 8bda225

Browse files
committed
Eliminate useless $this related check
1 parent 5ebefa7 commit 8bda225

File tree

7 files changed

+45
-33
lines changed

7 files changed

+45
-33
lines changed

ext/date/php_date.c

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3269,7 +3269,8 @@ PHP_METHOD(DateTimeImmutable, modify)
32693269
char *modify;
32703270
size_t modify_len;
32713271

3272-
if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Os", &object, date_ce_immutable, &modify, &modify_len) == FAILURE) {
3272+
object = &EX(This);
3273+
if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &modify, &modify_len) == FAILURE) {
32733274
RETURN_FALSE;
32743275
}
32753276

@@ -3322,7 +3323,8 @@ PHP_METHOD(DateTimeImmutable, add)
33223323
{
33233324
zval *object, *interval, new_object;
33243325

3325-
if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "OO", &object, date_ce_immutable, &interval, date_ce_interval) == FAILURE) {
3326+
object = &EX(This);
3327+
if (zend_parse_parameters(ZEND_NUM_ARGS(), "O", &interval, date_ce_interval) == FAILURE) {
33263328
RETURN_FALSE;
33273329
}
33283330

@@ -3378,7 +3380,8 @@ PHP_METHOD(DateTimeImmutable, sub)
33783380
{
33793381
zval *object, *interval, new_object;
33803382

3381-
if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "OO", &object, date_ce_immutable, &interval, date_ce_interval) == FAILURE) {
3383+
object = &EX(This);
3384+
if (zend_parse_parameters(ZEND_NUM_ARGS(), "O", &interval, date_ce_interval) == FAILURE) {
33823385
RETURN_FALSE;
33833386
}
33843387

@@ -3482,7 +3485,8 @@ PHP_METHOD(DateTimeImmutable, setTimezone)
34823485
zval *object, new_object;
34833486
zval *timezone_object;
34843487

3485-
if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "OO", &object, date_ce_immutable, &timezone_object, date_ce_timezone) == FAILURE) {
3488+
object = &EX(This);
3489+
if (zend_parse_parameters(ZEND_NUM_ARGS(), "O", &timezone_object, date_ce_timezone) == FAILURE) {
34863490
RETURN_FALSE;
34873491
}
34883492

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

3570-
if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Oll|ll", &object, date_ce_immutable, &h, &i, &s, &ms) == FAILURE) {
3574+
object = &EX(This);
3575+
if (zend_parse_parameters(ZEND_NUM_ARGS(), "ll|ll", &h, &i, &s, &ms) == FAILURE) {
35713576
RETURN_FALSE;
35723577
}
35733578

@@ -3616,7 +3621,8 @@ PHP_METHOD(DateTimeImmutable, setDate)
36163621
zval *object, new_object;
36173622
zend_long y, m, d;
36183623

3619-
if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Olll", &object, date_ce_immutable, &y, &m, &d) == FAILURE) {
3624+
object = &EX(This);
3625+
if (zend_parse_parameters(ZEND_NUM_ARGS(), "lll", &y, &m, &d) == FAILURE) {
36203626
RETURN_FALSE;
36213627
}
36223628

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

3672-
if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Oll|l", &object, date_ce_immutable, &y, &w, &d) == FAILURE) {
3678+
object = &EX(This);
3679+
if (zend_parse_parameters(ZEND_NUM_ARGS(), "ll|l", &y, &w, &d) == FAILURE) {
36733680
RETURN_FALSE;
36743681
}
36753682

@@ -3717,7 +3724,8 @@ PHP_METHOD(DateTimeImmutable, setTimestamp)
37173724
zval *object, new_object;
37183725
zend_long timestamp;
37193726

3720-
if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Ol", &object, date_ce_immutable, &timestamp) == FAILURE) {
3727+
object = &EX(This);
3728+
if (zend_parse_parameters(ZEND_NUM_ARGS(), "l", &timestamp) == FAILURE) {
37213729
RETURN_FALSE;
37223730
}
37233731

ext/intl/breakiterator/breakiterator_methods.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ U_CFUNC PHP_FUNCTION(breakiter_create_code_point_instance)
130130
U_CFUNC PHP_FUNCTION(breakiter_get_text)
131131
{
132132
BREAKITER_METHOD_INIT_VARS;
133-
object = getThis();
133+
object = &EX(This);
134134

135135
if (zend_parse_parameters_none() == FAILURE) {
136136
intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR,
@@ -152,7 +152,7 @@ U_CFUNC PHP_FUNCTION(breakiter_set_text)
152152
UText *ut = NULL;
153153
zend_string *text;
154154
BREAKITER_METHOD_INIT_VARS;
155-
object = getThis();
155+
object = &EX(This);
156156

157157
if (zend_parse_parameters(ZEND_NUM_ARGS(), "S", &text) == FAILURE) {
158158
intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR,
@@ -186,7 +186,7 @@ static void _breakiter_no_args_ret_int32(
186186
{
187187
char *msg;
188188
BREAKITER_METHOD_INIT_VARS;
189-
object = getThis();
189+
object = &EX(This);
190190

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

215215
if (zend_parse_parameters(ZEND_NUM_ARGS(), "l", &arg) == FAILURE) {
216216
spprintf(&msg, 0, "%s: bad arguments", func_name);
@@ -287,7 +287,7 @@ U_CFUNC PHP_FUNCTION(breakiter_next)
287287
U_CFUNC PHP_FUNCTION(breakiter_current)
288288
{
289289
BREAKITER_METHOD_INIT_VARS;
290-
object = getThis();
290+
object = &EX(This);
291291

292292
if (zend_parse_parameters_none() == FAILURE) {
293293
intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR,
@@ -320,7 +320,7 @@ U_CFUNC PHP_FUNCTION(breakiter_is_boundary)
320320
{
321321
zend_long offset;
322322
BREAKITER_METHOD_INIT_VARS;
323-
object = getThis();
323+
object = &EX(This);
324324

325325
if (zend_parse_parameters(ZEND_NUM_ARGS(), "l",
326326
&offset) == FAILURE) {
@@ -347,7 +347,7 @@ U_CFUNC PHP_FUNCTION(breakiter_get_locale)
347347
{
348348
zend_long locale_type;
349349
BREAKITER_METHOD_INIT_VARS;
350-
object = getThis();
350+
object = &EX(This);
351351

352352
if (zend_parse_parameters(ZEND_NUM_ARGS(), "l", &locale_type) == FAILURE) {
353353
intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR,
@@ -375,7 +375,7 @@ U_CFUNC PHP_FUNCTION(breakiter_get_parts_iterator)
375375
{
376376
zend_long key_type = 0;
377377
BREAKITER_METHOD_INIT_VARS;
378-
object = getThis();
378+
object = &EX(This);
379379

380380
if (zend_parse_parameters(ZEND_NUM_ARGS(), "|l", &key_type) == FAILURE) {
381381
intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR,
@@ -400,7 +400,7 @@ U_CFUNC PHP_FUNCTION(breakiter_get_parts_iterator)
400400
U_CFUNC PHP_FUNCTION(breakiter_get_error_code)
401401
{
402402
BREAKITER_METHOD_INIT_VARS;
403-
object = getThis();
403+
object = &EX(This);
404404

405405
if (zend_parse_parameters_none() == FAILURE) {
406406
intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR,
@@ -420,7 +420,7 @@ U_CFUNC PHP_FUNCTION(breakiter_get_error_message)
420420
{
421421
zend_string* message = NULL;
422422
BREAKITER_METHOD_INIT_VARS;
423-
object = getThis();
423+
object = &EX(This);
424424

425425
if (zend_parse_parameters_none() == FAILURE) {
426426
intl_error_set( NULL, U_ILLEGAL_ARGUMENT_ERROR,

ext/intl/breakiterator/codepointiterator_methods.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ static inline CodePointBreakIterator *fetch_cpbi(BreakIterator_object *bio) {
3030
U_CFUNC PHP_FUNCTION(cpbi_get_last_code_point)
3131
{
3232
BREAKITER_METHOD_INIT_VARS;
33-
object = getThis();
33+
object = &EX(This);
3434

3535
if (zend_parse_parameters_none() == FAILURE) {
3636
intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR,

ext/intl/breakiterator/rulebasedbreakiterator_methods.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ U_CFUNC PHP_METHOD(IntlRuleBasedBreakIterator, __construct)
102102
U_CFUNC PHP_FUNCTION(rbbi_get_rules)
103103
{
104104
BREAKITER_METHOD_INIT_VARS;
105-
object = getThis();
105+
object = &EX(This);
106106

107107
if (zend_parse_parameters_none() == FAILURE) {
108108
intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR,
@@ -129,7 +129,7 @@ U_CFUNC PHP_FUNCTION(rbbi_get_rules)
129129
U_CFUNC PHP_FUNCTION(rbbi_get_rule_status)
130130
{
131131
BREAKITER_METHOD_INIT_VARS;
132-
object = getThis();
132+
object = &EX(This);
133133

134134
if (zend_parse_parameters_none() == FAILURE) {
135135
intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR,
@@ -145,7 +145,7 @@ U_CFUNC PHP_FUNCTION(rbbi_get_rule_status)
145145
U_CFUNC PHP_FUNCTION(rbbi_get_rule_status_vec)
146146
{
147147
BREAKITER_METHOD_INIT_VARS;
148-
object = getThis();
148+
object = &EX(This);
149149

150150
if (zend_parse_parameters_none() == FAILURE) {
151151
intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR,
@@ -185,7 +185,7 @@ U_CFUNC PHP_FUNCTION(rbbi_get_rule_status_vec)
185185
U_CFUNC PHP_FUNCTION(rbbi_get_binary_rules)
186186
{
187187
BREAKITER_METHOD_INIT_VARS;
188-
object = getThis();
188+
object = &EX(This);
189189

190190
if (zend_parse_parameters_none() == FAILURE) {
191191
intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR,

ext/intl/calendar/calendar_methods.cpp

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -409,23 +409,25 @@ U_CFUNC PHP_FUNCTION(intlcal_set)
409409
int variant; /* number of args of the set() overload */
410410
CALENDAR_METHOD_INIT_VARS;
411411

412+
object = getThis();
413+
412414
/* must come before zpp because zpp would convert the args in the stack to 0 */
413-
if (ZEND_NUM_ARGS() > (getThis() ? 6 : 7) ||
415+
if (ZEND_NUM_ARGS() > (object ? 6 : 7) ||
414416
zend_get_parameters_array_ex(ZEND_NUM_ARGS(), args) == FAILURE) {
415417
intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR,
416418
"intlcal_set: too many arguments", 0);
417419
RETURN_FALSE;
418420
}
419-
if (!getThis()) {
421+
if (!object) {
420422
args++;
421423
}
422-
variant = ZEND_NUM_ARGS() - (getThis() ? 0 : 1);
424+
variant = ZEND_NUM_ARGS() - (object ? 0 : 1);
423425
while (variant > 2 && Z_TYPE(args[variant - 1]) == IS_NULL) {
424426
variant--;
425427
}
426428

427429
if (variant == 4 ||
428-
zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(),
430+
zend_parse_method_parameters(ZEND_NUM_ARGS(), object,
429431
"Oll|llll", &object, Calendar_ce_ptr, &arg1, &arg2, &arg3, &arg4,
430432
&arg5, &arg6) == FAILURE) {
431433
intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR,
@@ -472,25 +474,27 @@ U_CFUNC PHP_FUNCTION(intlcal_roll)
472474
zend_bool bool_variant_val = (zend_bool)-1;
473475
CALENDAR_METHOD_INIT_VARS;
474476

475-
if (ZEND_NUM_ARGS() > (getThis() ? 2 :3) ||
477+
object = getThis();
478+
479+
if (ZEND_NUM_ARGS() > (object ? 2 :3) ||
476480
zend_get_parameters_array_ex(ZEND_NUM_ARGS(), args) == FAILURE) {
477481
intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR,
478482
"intlcal_set: too many arguments", 0);
479483
RETURN_FALSE;
480484
}
481-
if (!getThis()) {
485+
if (!object) {
482486
args++;
483487
}
484488
if (!Z_ISUNDEF(args[1]) && (Z_TYPE(args[1]) == IS_TRUE || Z_TYPE(args[1]) == IS_FALSE)) {
485-
if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(),
489+
if (zend_parse_method_parameters(ZEND_NUM_ARGS(), object,
486490
"Olb", &object, Calendar_ce_ptr, &field, &bool_variant_val)
487491
== FAILURE) {
488492
intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR,
489493
"intlcal_roll: bad arguments", 0);
490494
RETURN_FALSE;
491495
}
492496
bool_variant_val = Z_TYPE(args[1]) == IS_TRUE? 1 : 0;
493-
} else if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(),
497+
} else if (zend_parse_method_parameters(ZEND_NUM_ARGS(), object,
494498
"Oll", &object, Calendar_ce_ptr, &field, &value) == FAILURE) {
495499
intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR,
496500
"intlcal_roll: bad arguments", 0);

ext/intl/common/common_enum.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ extern "C" {
4040
#define INTLITERATOR_METHOD_INIT_VARS INTL_METHOD_INIT_VARS(IntlIterator, ii)
4141
#define INTLITERATOR_METHOD_FETCH_OBJECT_NO_CHECK INTL_METHOD_FETCH_OBJECT(INTL_ITERATOR, ii)
4242
#define INTLITERATOR_METHOD_FETCH_OBJECT\
43-
object = getThis(); \
43+
object = &EX(This); \
4444
INTLITERATOR_METHOD_FETCH_OBJECT_NO_CHECK; \
4545
if (ii->iterator == NULL) { \
4646
intl_errors_set(&ii->err, U_ILLEGAL_ARGUMENT_ERROR, "Found unconstructed IntlIterator", 0); \

ext/intl/spoofchecker/spoofchecker_class.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ extern zend_class_entry *Spoofchecker_ce_ptr;
5757
/* Auxiliary macros */
5858

5959
#define SPOOFCHECKER_METHOD_INIT_VARS \
60-
zval* object = getThis(); \
60+
zval* object = &EX(This); \
6161
Spoofchecker_object* co = NULL; \
6262
intl_error_reset(NULL); \
6363

0 commit comments

Comments
 (0)