Skip to content

Commit 3db6f93

Browse files
committed
Coding style
1 parent b4da034 commit 3db6f93

File tree

1 file changed

+22
-22
lines changed

1 file changed

+22
-22
lines changed

Zend/zend_inheritance.c

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ typedef enum {
273273
* the fact that they are inverses to improve correctness and simplify code.
274274
* We can implement covariance, and then implement contravariance simply by
275275
* reversing the argument order. */
276-
static inheritance_status _check_covariance(
276+
static inheritance_status check_covariance(
277277
const zend_function *fe, zend_arg_info *fe_arg_info,
278278
const zend_function *proto, zend_arg_info *proto_arg_info)
279279
{ /* {{{ */
@@ -346,7 +346,7 @@ static inheritance_status _check_covariance(
346346
}
347347
/* }}} */
348348

349-
static inheritance_status _check_inherited_return_type(
349+
static inheritance_status check_inherited_return_type(
350350
const zend_function *fe, zend_arg_info *fe_arg_info,
351351
const zend_function *proto, zend_arg_info *proto_arg_info) /* {{{ */
352352
{
@@ -355,21 +355,20 @@ static inheritance_status _check_inherited_return_type(
355355
return INHERITANCE_ERROR;
356356
}
357357

358-
return _check_covariance(fe, fe_arg_info, proto, proto_arg_info);
358+
return check_covariance(fe, fe_arg_info, proto, proto_arg_info);
359359
}
360360

361-
362-
static zend_bool _missing_internal_arginfo(zend_function const *fn)
361+
static zend_bool missing_internal_arginfo(zend_function const *fn)
363362
{
364363
return !fn->common.arg_info && fn->common.type == ZEND_INTERNAL_FUNCTION;
365364
}
366365

367-
static inheritance_status _check_inherited_parameter_type(
366+
static inheritance_status check_inherited_parameter_type(
368367
const zend_function *fe, zend_arg_info *fe_arg_info,
369368
const zend_function *proto, zend_arg_info *proto_arg_info) /* {{{ */
370369
{
371370

372-
/* by-ref constraints on arguments are invariant */
371+
/* By-ref constraints on arguments are invariant */
373372
if (fe_arg_info->pass_by_reference != proto_arg_info->pass_by_reference) {
374373
return INHERITANCE_ERROR;
375374
}
@@ -385,7 +384,7 @@ static inheritance_status _check_inherited_parameter_type(
385384
}
386385

387386
/* CONTRAVARIANT is inverse of COVARIANT, so call with reversed args. */
388-
return _check_covariance(proto, proto_arg_info, fe, fe_arg_info);
387+
return check_covariance(proto, proto_arg_info, fe, fe_arg_info);
389388
}
390389
/* }}} */
391390

@@ -399,7 +398,7 @@ static inheritance_status zend_do_perform_implementation_check(
399398
* we still need to do the arg number checks. We are only willing to ignore this for internal
400399
* functions because extensions don't always define arg_info.
401400
*/
402-
if (_missing_internal_arginfo(proto)) {
401+
if (missing_internal_arginfo(proto)) {
403402
return INHERITANCE_SUCCESS;
404403
}
405404

@@ -458,7 +457,7 @@ static inheritance_status zend_do_perform_implementation_check(
458457
: &proto->common.arg_info[proto->common.num_args];
459458

460459
inheritance_status local_status =
461-
_check_inherited_parameter_type(fe, fe_arg_info, proto, proto_arg_info);
460+
check_inherited_parameter_type(fe, fe_arg_info, proto, proto_arg_info);
462461
if (local_status == INHERITANCE_ERROR) {
463462
return INHERITANCE_ERROR;
464463
} else if (local_status == INHERITANCE_UNRESOLVED) {
@@ -470,7 +469,7 @@ static inheritance_status zend_do_perform_implementation_check(
470469
* a return type. Adding a new return type is always valid. */
471470
if (proto->common.fn_flags & ZEND_ACC_HAS_RETURN_TYPE) {
472471
inheritance_status local_result =
473-
_check_inherited_return_type(
472+
check_inherited_return_type(
474473
fe, fe->common.arg_info - 1, proto, proto->common.arg_info - 1);
475474
if (local_result == INHERITANCE_ERROR) {
476475
return INHERITANCE_ERROR;
@@ -750,7 +749,7 @@ static void do_inheritance_check_on_method(zend_function *child, zend_function *
750749
error_level = E_COMPILE_ERROR;
751750
error_verb = "must";
752751
} else if ((parent->common.fn_flags & ZEND_ACC_HAS_RETURN_TYPE) &&
753-
!_check_inherited_return_type(child, child->common.arg_info - 1, parent, parent->common.arg_info - 1)) {
752+
!check_inherited_return_type(child, child->common.arg_info - 1, parent, parent->common.arg_info - 1)) {
754753
error_level = E_COMPILE_ERROR;
755754
error_verb = "must";
756755
} else {
@@ -2181,15 +2180,15 @@ ZEND_API void zend_do_link_class(zend_class_entry *ce, zend_class_entry *parent)
21812180
}
21822181
/* }}} */
21832182

2184-
static void _inheritance_runtime_error_msg(zend_function *child, zend_function *parent)
2183+
static void inheritance_runtime_error_msg(zend_function *child, zend_function *parent)
21852184
{
21862185
int level = E_WARNING;
21872186
const char *verb = "should";
21882187
ZEND_ASSERT(child && parent);
21892188
if ((parent->common.fn_flags & ZEND_ACC_ABSTRACT)
21902189
|| (
21912190
(parent->common.fn_flags & ZEND_ACC_HAS_RETURN_TYPE)
2192-
&& _check_inherited_return_type(child, child->common.arg_info - 1,
2191+
&& check_inherited_return_type(child, child->common.arg_info - 1,
21932192
parent, parent->common.arg_info - 1) != INHERITANCE_SUCCESS
21942193
))
21952194
{
@@ -2232,7 +2231,7 @@ ZEND_API void zend_verify_variance(zend_class_entry *ce)
22322231

22332232
/* We are only willing to ignore this for internal functions because
22342233
* extensions don't always define arg_info. */
2235-
if (_missing_internal_arginfo(parent)) {
2234+
if (missing_internal_arginfo(parent)) {
22362235
continue;
22372236
}
22382237

@@ -2254,11 +2253,13 @@ ZEND_API void zend_verify_variance(zend_class_entry *ce)
22542253
* specifies a return type. Adding a new return type is always valid. */
22552254
if (parent->common.fn_flags & ZEND_ACC_HAS_RETURN_TYPE) {
22562255
if (child->common.fn_flags & ZEND_ACC_HAS_RETURN_TYPE) {
2257-
int check = _check_inherited_return_type(
2256+
inheritance_status status = check_inherited_return_type(
22582257
child, &child->common.arg_info[-1],
22592258
parent, &parent->common.arg_info[-1]);
2260-
if (check < 0) {
2261-
_inheritance_runtime_error_msg(child, parent);
2259+
/* TODO I don't think this is right -- what if the class now exists
2260+
* but has wrong variance? */
2261+
if (status == INHERITANCE_UNRESOLVED) {
2262+
inheritance_runtime_error_msg(child, parent);
22622263
continue;
22632264
}
22642265
} else {
@@ -2291,12 +2292,11 @@ ZEND_API void zend_verify_variance(zend_class_entry *ce)
22912292
? &parent->common.arg_info[i]
22922293
: &parent->common.arg_info[parent->common.num_args];
22932294

2294-
int check = _check_inherited_parameter_type(
2295+
inheritance_status status = check_inherited_parameter_type(
22952296
child, child_arg_info,
22962297
parent, parent_arg_info);
2297-
2298-
if (check < 0) {
2299-
_inheritance_runtime_error_msg(child, parent);
2298+
if (status == INHERITANCE_UNRESOLVED) {
2299+
inheritance_runtime_error_msg(child, parent);
23002300
continue;
23012301
}
23022302
}

0 commit comments

Comments
 (0)