Skip to content

Commit f4ded49

Browse files
committed
Don't return inside _DO_THROW macro
Returning inside _DO_THROW() is kind of pointless if we are going to comment most uses with "this is gonna return".
1 parent 248f9cf commit f4ded49

File tree

1 file changed

+18
-14
lines changed

1 file changed

+18
-14
lines changed

ext/reflection/php_reflection.c

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,7 @@ PHPAPI zend_class_entry *reflection_reference_ptr;
8989

9090
/* Exception throwing macro */
9191
#define _DO_THROW(msg) \
92-
zend_throw_exception(reflection_exception_ptr, msg, 0); \
93-
return;
92+
zend_throw_exception(reflection_exception_ptr, msg, 0);
9493

9594
#define GET_REFLECTION_OBJECT() do { \
9695
intern = Z_REFLECTION_P(ZEND_THIS); \
@@ -1305,6 +1304,7 @@ static void _reflection_export(INTERNAL_FUNCTION_PARAMETERS, zend_class_entry *c
13051304
/* Create object */
13061305
if (object_init_ex(&reflector, ce_ptr) == FAILURE) {
13071306
_DO_THROW("Could not create reflector");
1307+
return;
13081308
}
13091309

13101310
/* Call __construct() */
@@ -1332,6 +1332,7 @@ static void _reflection_export(INTERNAL_FUNCTION_PARAMETERS, zend_class_entry *c
13321332
if (result == FAILURE) {
13331333
zval_ptr_dtor(&reflector);
13341334
_DO_THROW("Could not create reflector");
1335+
return;
13351336
}
13361337

13371338
/* Call static reflection::export */
@@ -1353,6 +1354,7 @@ static void _reflection_export(INTERNAL_FUNCTION_PARAMETERS, zend_class_entry *c
13531354
zval_ptr_dtor(&reflector);
13541355
zval_ptr_dtor(&retval);
13551356
_DO_THROW("Could not execute reflection::export()");
1357+
return;
13561358
}
13571359

13581360
if (return_output) {
@@ -1439,7 +1441,7 @@ ZEND_METHOD(reflection, export)
14391441

14401442
if (result == FAILURE) {
14411443
_DO_THROW("Invocation of method __toString() failed");
1442-
/* Returns from this function */
1444+
return;
14431445
}
14441446

14451447
if (Z_TYPE(retval) == IS_UNDEF) {
@@ -2286,7 +2288,7 @@ ZEND_METHOD(reflection_parameter, __construct)
22862288
|| ((method = zend_hash_index_find(Z_ARRVAL_P(reference), 1)) == NULL))
22872289
{
22882290
_DO_THROW("Expected array($object, $method) or array($classname, $method)");
2289-
/* returns out of this function */
2291+
return;
22902292
}
22912293

22922294
if (Z_TYPE_P(classref) == IS_OBJECT) {
@@ -2334,7 +2336,7 @@ ZEND_METHOD(reflection_parameter, __construct)
23342336

23352337
default:
23362338
_DO_THROW("The parameter class is expected to be either a string, an array(class, method) or a callable object");
2337-
/* returns out of this function */
2339+
return;
23382340
}
23392341

23402342
/* Now, search for the parameter */
@@ -2356,7 +2358,7 @@ ZEND_METHOD(reflection_parameter, __construct)
23562358
zval_ptr_dtor(reference);
23572359
}
23582360
_DO_THROW("The parameter specified by its offset could not be found");
2359-
/* returns out of this function */
2361+
return;
23602362
}
23612363
} else {
23622364
uint32_t i;
@@ -2395,7 +2397,7 @@ ZEND_METHOD(reflection_parameter, __construct)
23952397
zval_ptr_dtor(reference);
23962398
}
23972399
_DO_THROW("The parameter specified by its name could not be found");
2398-
/* returns out of this function */
2400+
return;
23992401
}
24002402
}
24012403

@@ -2980,7 +2982,7 @@ ZEND_METHOD(reflection_method, __construct)
29802982
zval_ptr_dtor_str(&ztmp);
29812983
}
29822984
_DO_THROW("The parameter class is expected to be either a string or an object");
2983-
/* returns out of this function */
2985+
return;
29842986
}
29852987

29862988
if (classname == &ztmp) {
@@ -3048,7 +3050,7 @@ ZEND_METHOD(reflection_method, getClosure)
30483050

30493051
if (!instanceof_function(Z_OBJCE_P(obj), mptr->common.scope)) {
30503052
_DO_THROW("Given object is not an instance of the class this method was declared in");
3051-
/* Returns from this function */
3053+
return;
30523054
}
30533055

30543056
/* This is an original closure object and __invoke is to be called. */
@@ -3137,7 +3139,7 @@ static void reflection_method_invoke(INTERNAL_FUNCTION_PARAMETERS, int variadic)
31373139
efree(params);
31383140
}
31393141
_DO_THROW("Given object is not an instance of the class this method was declared in");
3140-
/* Returns from this function */
3142+
return;
31413143
}
31423144
}
31433145

@@ -3520,7 +3522,7 @@ ZEND_METHOD(reflection_class_constant, __construct)
35203522

35213523
default:
35223524
_DO_THROW("The parameter class is expected to be either a string or an object");
3523-
/* returns out of this function */
3525+
return;
35243526
}
35253527

35263528
if ((constant = zend_hash_find_ptr(&ce->constants_table, constname)) == NULL) {
@@ -5242,7 +5244,7 @@ ZEND_METHOD(reflection_property, __construct)
52425244

52435245
default:
52445246
_DO_THROW("The parameter class is expected to be either a string or an object");
5245-
/* returns out of this function */
5247+
return;
52465248
}
52475249

52485250
property_info = zend_hash_find_ptr(&ce->properties_info, name);
@@ -5439,7 +5441,7 @@ ZEND_METHOD(reflection_property, getValue)
54395441

54405442
if (!instanceof_function(Z_OBJCE_P(object), ref->prop.ce)) {
54415443
_DO_THROW("Given object is not an instance of the class this property was declared in");
5442-
/* Returns from this function */
5444+
return;
54435445
}
54445446

54455447
member_p = zend_read_property_ex(intern->ce, object, ref->unmangled_name, 0, &rv);
@@ -5527,7 +5529,7 @@ ZEND_METHOD(reflection_property, isInitialized)
55275529

55285530
if (!instanceof_function(Z_OBJCE_P(object), ref->prop.ce)) {
55295531
_DO_THROW("Given object is not an instance of the class this property was declared in");
5530-
/* Returns from this function */
5532+
return;
55315533
}
55325534

55335535
old_scope = EG(fake_scope);
@@ -6191,6 +6193,7 @@ ZEND_METHOD(reflection_reference, fromArrayElement)
61916193

61926194
if (!item) {
61936195
_DO_THROW("Array key not found");
6196+
return;
61946197
}
61956198

61966199
if (Z_TYPE_P(item) != IS_REFERENCE) {
@@ -6220,6 +6223,7 @@ ZEND_METHOD(reflection_reference, getId)
62206223
intern = Z_REFLECTION_P(getThis());
62216224
if (Z_TYPE(intern->obj) != IS_REFERENCE) {
62226225
_DO_THROW("Corrupted ReflectionReference object");
6226+
return;
62236227
}
62246228

62256229
if (!REFLECTION_G(key_initialized)) {

0 commit comments

Comments
 (0)