diff --git a/src/php/ext/grpc/call.c b/src/php/ext/grpc/call.c index 3f96db7ccb1..d455002de6d 100644 --- a/src/php/ext/grpc/call.c +++ b/src/php/ext/grpc/call.c @@ -380,8 +380,6 @@ PHP_METHOD(Call, __construct) { */ PHP_METHOD(Call, startBatch) { #if PHP_MAJOR_VERSION < 7 - wrapped_grpc_call *call = - (wrapped_grpc_call *)zend_object_store_get_object(getThis() TSRMLS_CC); zval **value; zval **inner_value; HashPosition array_pointer; @@ -395,7 +393,6 @@ PHP_METHOD(Call, startBatch) { MAKE_STD_ZVAL(result); object_init(result); #else - wrapped_grpc_call *call = Z_WRAPPED_GRPC_CALL_P(getThis()); zval *value; zval *inner_value; zval *message_value; @@ -405,6 +402,7 @@ PHP_METHOD(Call, startBatch) { zval recv_status; object_init(return_value); #endif + wrapped_grpc_call *call = Z_WRAPPED_GRPC_CALL_P(getThis()); grpc_op ops[8]; size_t op_num = 0; @@ -829,14 +827,8 @@ cleanup: * @return string The URI of the endpoint */ PHP_METHOD(Call, getPeer) { -#if PHP_MAJOR_VERSION < 7 - wrapped_grpc_call *call = - (wrapped_grpc_call *)zend_object_store_get_object(getThis() TSRMLS_CC); - RETURN_STRING(grpc_call_get_peer(call->wrapped), 1); -#else wrapped_grpc_call *call = Z_WRAPPED_GRPC_CALL_P(getThis()); - RETURN_STRING(grpc_call_get_peer(call->wrapped)); -#endif + PHP_GRPC_RETURN_STRING(grpc_call_get_peer(call->wrapped), 1); } /** @@ -844,12 +836,7 @@ PHP_METHOD(Call, getPeer) { * has not already ended with another status. */ PHP_METHOD(Call, cancel) { -#if PHP_MAJOR_VERSION < 7 - wrapped_grpc_call *call = - (wrapped_grpc_call *)zend_object_store_get_object(getThis() TSRMLS_CC); -#else wrapped_grpc_call *call = Z_WRAPPED_GRPC_CALL_P(getThis()); -#endif grpc_call_cancel(call->wrapped, NULL); } diff --git a/src/php/ext/grpc/timeval.c b/src/php/ext/grpc/timeval.c index db0f8a7aaf4..a3ec62f13f4 100644 --- a/src/php/ext/grpc/timeval.c +++ b/src/php/ext/grpc/timeval.c @@ -124,12 +124,7 @@ void grpc_php_wrap_timeval(gpr_timespec wrapped, zval *timeval_object) { * @param long $usec The number of microseconds in the interval */ PHP_METHOD(Timeval, __construct) { -#if PHP_MAJOR_VERSION < 7 - wrapped_grpc_timeval *timeval = - (wrapped_grpc_timeval *)zend_object_store_get_object(getThis() TSRMLS_CC); -#else wrapped_grpc_timeval *timeval = Z_WRAPPED_GRPC_TIMEVAL_P(getThis()); -#endif php_grpc_long microseconds; /* "l" == 1 long */ @@ -159,19 +154,14 @@ PHP_METHOD(Timeval, add) { "add expects a Timeval", 1 TSRMLS_CC); return; } + wrapped_grpc_timeval *self = Z_WRAPPED_GRPC_TIMEVAL_P(getThis()); + wrapped_grpc_timeval *other = Z_WRAPPED_GRPC_TIMEVAL_P(other_obj); #if PHP_MAJOR_VERSION < 7 - wrapped_grpc_timeval *self = - (wrapped_grpc_timeval *)zend_object_store_get_object(getThis() TSRMLS_CC); - wrapped_grpc_timeval *other = - (wrapped_grpc_timeval *)zend_object_store_get_object(other_obj TSRMLS_CC); zval *sum = grpc_php_wrap_timeval(gpr_time_add(self->wrapped, other->wrapped) TSRMLS_CC); RETURN_DESTROY_ZVAL(sum); #else - wrapped_grpc_timeval *self = Z_WRAPPED_GRPC_TIMEVAL_P(getThis()); - wrapped_grpc_timeval *other = Z_WRAPPED_GRPC_TIMEVAL_P(other_obj); - grpc_php_wrap_timeval(gpr_time_add(self->wrapped, other->wrapped), return_value); RETURN_DESTROY_ZVAL(return_value); @@ -194,18 +184,14 @@ PHP_METHOD(Timeval, subtract) { "subtract expects a Timeval", 1 TSRMLS_CC); return; } + wrapped_grpc_timeval *self = Z_WRAPPED_GRPC_TIMEVAL_P(getThis()); + wrapped_grpc_timeval *other = Z_WRAPPED_GRPC_TIMEVAL_P(other_obj); #if PHP_MAJOR_VERSION < 7 - wrapped_grpc_timeval *self = - (wrapped_grpc_timeval *)zend_object_store_get_object(getThis() TSRMLS_CC); - wrapped_grpc_timeval *other = - (wrapped_grpc_timeval *)zend_object_store_get_object(other_obj TSRMLS_CC); zval *diff = grpc_php_wrap_timeval(gpr_time_sub(self->wrapped, other->wrapped) TSRMLS_CC); RETURN_DESTROY_ZVAL(diff); #else - wrapped_grpc_timeval *self = Z_WRAPPED_GRPC_TIMEVAL_P(getThis()); - wrapped_grpc_timeval *other = Z_WRAPPED_GRPC_TIMEVAL_P(other_obj); grpc_php_wrap_timeval(gpr_time_sub(self->wrapped, other->wrapped), return_value); RETURN_DESTROY_ZVAL(return_value); @@ -231,15 +217,8 @@ PHP_METHOD(Timeval, compare) { "compare expects two Timevals", 1 TSRMLS_CC); return; } -#if PHP_MAJOR_VERSION < 7 - wrapped_grpc_timeval *a = - (wrapped_grpc_timeval *)zend_object_store_get_object(a_obj TSRMLS_CC); - wrapped_grpc_timeval *b = - (wrapped_grpc_timeval *)zend_object_store_get_object(b_obj TSRMLS_CC); -#else wrapped_grpc_timeval *a = Z_WRAPPED_GRPC_TIMEVAL_P(a_obj); wrapped_grpc_timeval *b = Z_WRAPPED_GRPC_TIMEVAL_P(b_obj); -#endif long result = gpr_time_cmp(a->wrapped, b->wrapped); RETURN_LONG(result); } @@ -264,19 +243,9 @@ PHP_METHOD(Timeval, similar) { "compare expects three Timevals", 1 TSRMLS_CC); return; } -#if PHP_MAJOR_VERSION < 7 - wrapped_grpc_timeval *a = - (wrapped_grpc_timeval *)zend_object_store_get_object(a_obj TSRMLS_CC); - wrapped_grpc_timeval *b = - (wrapped_grpc_timeval *)zend_object_store_get_object(b_obj TSRMLS_CC); - wrapped_grpc_timeval *thresh = - (wrapped_grpc_timeval *)zend_object_store_get_object( - thresh_obj TSRMLS_CC); -#else wrapped_grpc_timeval *a = Z_WRAPPED_GRPC_TIMEVAL_P(a_obj); wrapped_grpc_timeval *b = Z_WRAPPED_GRPC_TIMEVAL_P(b_obj); wrapped_grpc_timeval *thresh = Z_WRAPPED_GRPC_TIMEVAL_P(thresh_obj); -#endif int result = gpr_time_similar(a->wrapped, b->wrapped, thresh->wrapped); RETURN_BOOL(result); } @@ -349,12 +318,7 @@ PHP_METHOD(Timeval, infPast) { * @return void */ PHP_METHOD(Timeval, sleepUntil) { -#if PHP_MAJOR_VERSION < 7 - wrapped_grpc_timeval *this = - (wrapped_grpc_timeval *)zend_object_store_get_object(getThis() TSRMLS_CC); -#else wrapped_grpc_timeval *this = Z_WRAPPED_GRPC_TIMEVAL_P(getThis()); -#endif gpr_sleep_until(this->wrapped); }