Skip to content

Commit 4f89211

Browse files
committed
Remove the deprecated reflection export methods
Closes GH-5188
1 parent 318fe06 commit 4f89211

17 files changed

+13
-626
lines changed

ext/com_dotnet/tests/bug45280.phpt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,9 @@ if (!extension_loaded("com_dotnet")){ echo "skip COM/.Net support not present";
88
<?php
99
$dict = new COM("Scripting.Dictionary");
1010

11+
$reflection = new ReflectionObject($dict);
1112
ob_start();
12-
ReflectionObject::export($dict);
13+
echo $reflection;
1314
ob_get_clean();
1415

1516
echo 'done';

ext/reflection/php_reflection.c

Lines changed: 0 additions & 194 deletions
Original file line numberDiff line numberDiff line change
@@ -1261,101 +1261,6 @@ static void reflection_class_constant_factory(zend_class_entry *ce, zend_string
12611261
}
12621262
/* }}} */
12631263

1264-
static void reflection_export_impl(zval *return_value, zval *object, zend_bool return_output) {
1265-
zval fname, retval;
1266-
int result;
1267-
1268-
/* Invoke the __toString() method */
1269-
ZVAL_STRINGL(&fname, "__tostring", sizeof("__tostring") - 1);
1270-
result = call_user_function(NULL, object, &fname, &retval, 0, NULL);
1271-
zval_ptr_dtor_str(&fname);
1272-
1273-
if (result == FAILURE) {
1274-
_DO_THROW("Invocation of method __toString() failed");
1275-
RETURN_THROWS();
1276-
}
1277-
1278-
if (Z_TYPE(retval) == IS_UNDEF) {
1279-
php_error_docref(NULL, E_WARNING, "%s::__toString() did not return anything", ZSTR_VAL(Z_OBJCE_P(object)->name));
1280-
RETURN_FALSE;
1281-
}
1282-
1283-
if (return_output) {
1284-
ZVAL_COPY_VALUE(return_value, &retval);
1285-
} else {
1286-
/* No need for _r variant, return of __toString should always be a string */
1287-
zend_print_zval(&retval, 0);
1288-
zend_printf("\n");
1289-
zval_ptr_dtor(&retval);
1290-
}
1291-
}
1292-
1293-
/* {{{ _reflection_export */
1294-
static void _reflection_export(INTERNAL_FUNCTION_PARAMETERS, zend_class_entry *ce_ptr, int ctor_argc)
1295-
{
1296-
zval reflector;
1297-
zval *argument_ptr, *argument2_ptr;
1298-
zval retval, params[2];
1299-
int result;
1300-
int return_output = 0;
1301-
zend_fcall_info fci;
1302-
zend_fcall_info_cache fcc;
1303-
1304-
if (ctor_argc == 1) {
1305-
if (zend_parse_parameters(ZEND_NUM_ARGS(), "z|b", &argument_ptr, &return_output) == FAILURE) {
1306-
RETURN_THROWS();
1307-
}
1308-
ZVAL_COPY_VALUE(&params[0], argument_ptr);
1309-
ZVAL_NULL(&params[1]);
1310-
} else {
1311-
if (zend_parse_parameters(ZEND_NUM_ARGS(), "zz|b", &argument_ptr, &argument2_ptr, &return_output) == FAILURE) {
1312-
RETURN_THROWS();
1313-
}
1314-
ZVAL_COPY_VALUE(&params[0], argument_ptr);
1315-
ZVAL_COPY_VALUE(&params[1], argument2_ptr);
1316-
}
1317-
1318-
/* Create object */
1319-
if (object_init_ex(&reflector, ce_ptr) == FAILURE) {
1320-
_DO_THROW("Could not create reflector");
1321-
RETURN_THROWS();
1322-
}
1323-
1324-
/* Call __construct() */
1325-
1326-
fci.size = sizeof(fci);
1327-
ZVAL_UNDEF(&fci.function_name);
1328-
fci.object = Z_OBJ(reflector);
1329-
fci.retval = &retval;
1330-
fci.param_count = ctor_argc;
1331-
fci.params = params;
1332-
fci.no_separation = 1;
1333-
1334-
fcc.function_handler = ce_ptr->constructor;
1335-
fcc.called_scope = Z_OBJCE(reflector);
1336-
fcc.object = Z_OBJ(reflector);
1337-
1338-
result = zend_call_function(&fci, &fcc);
1339-
1340-
zval_ptr_dtor(&retval);
1341-
1342-
if (EG(exception)) {
1343-
zval_ptr_dtor(&reflector);
1344-
RETURN_THROWS();
1345-
}
1346-
if (result == FAILURE) {
1347-
zval_ptr_dtor(&reflector);
1348-
_DO_THROW("Could not create reflector");
1349-
RETURN_THROWS();
1350-
}
1351-
1352-
reflection_export_impl(return_value, &reflector, return_output);
1353-
1354-
/* Destruct reflector which is no longer needed */
1355-
zval_ptr_dtor(&reflector);
1356-
}
1357-
/* }}} */
1358-
13591264
/* {{{ _reflection_param_get_default_param */
13601265
static parameter_reference *_reflection_param_get_default_param(INTERNAL_FUNCTION_PARAMETERS)
13611266
{
@@ -1408,23 +1313,6 @@ ZEND_METHOD(reflection, __clone)
14081313
}
14091314
/* }}} */
14101315

1411-
/* {{{ proto public static mixed Reflection::export(Reflector r [, bool return])
1412-
Exports a reflection object. Returns the output if TRUE is specified for return, printing it otherwise. */
1413-
ZEND_METHOD(reflection, export)
1414-
{
1415-
zval *object;
1416-
zend_bool return_output = 0;
1417-
1418-
ZEND_PARSE_PARAMETERS_START(1, 2)
1419-
Z_PARAM_OBJECT_OF_CLASS(object, reflector_ptr)
1420-
Z_PARAM_OPTIONAL
1421-
Z_PARAM_BOOL(return_output)
1422-
ZEND_PARSE_PARAMETERS_END();
1423-
1424-
reflection_export_impl(return_value, object, return_output);
1425-
}
1426-
/* }}} */
1427-
14281316
/* {{{ proto public static array Reflection::getModifierNames(int modifiers)
14291317
Returns an array of modifier names */
14301318
ZEND_METHOD(reflection, getModifierNames)
@@ -1463,14 +1351,6 @@ ZEND_METHOD(reflection, getModifierNames)
14631351
}
14641352
/* }}} */
14651353

1466-
/* {{{ proto public static mixed ReflectionFunction::export(string name [, bool return])
1467-
Exports a reflection object. Returns the output if TRUE is specified for return, printing it otherwise. */
1468-
ZEND_METHOD(reflection_function, export)
1469-
{
1470-
_reflection_export(INTERNAL_FUNCTION_PARAM_PASSTHRU, reflection_function_ptr, 1);
1471-
}
1472-
/* }}} */
1473-
14741354
/* {{{ proto public void ReflectionFunction::__construct(string name)
14751355
Constructor. Throws an Exception in case the given function does not exist */
14761356
ZEND_METHOD(reflection_function, __construct)
@@ -2227,14 +2107,6 @@ ZEND_METHOD(reflection_generator, getExecutingGenerator)
22272107
}
22282108
/* }}} */
22292109

2230-
/* {{{ proto public static mixed ReflectionParameter::export(mixed function, mixed parameter [, bool return]) throws ReflectionException
2231-
Exports a reflection object. Returns the output if TRUE is specified for return, printing it otherwise. */
2232-
ZEND_METHOD(reflection_parameter, export)
2233-
{
2234-
_reflection_export(INTERNAL_FUNCTION_PARAM_PASSTHRU, reflection_parameter_ptr, 2);
2235-
}
2236-
/* }}} */
2237-
22382110
/* {{{ proto public void ReflectionParameter::__construct(mixed function, mixed parameter)
22392111
Constructor. Throws an Exception in case the given method does not exist */
22402112
ZEND_METHOD(reflection_parameter, __construct)
@@ -2986,14 +2858,6 @@ ZEND_METHOD(reflection_union_type, getTypes)
29862858
}
29872859
/* }}} */
29882860

2989-
/* {{{ proto public static mixed ReflectionMethod::export(mixed class, string name [, bool return]) throws ReflectionException
2990-
Exports a reflection object. Returns the output if TRUE is specified for return, printing it otherwise. */
2991-
ZEND_METHOD(reflection_method, export)
2992-
{
2993-
_reflection_export(INTERNAL_FUNCTION_PARAM_PASSTHRU, reflection_method_ptr, 2);
2994-
}
2995-
/* }}} */
2996-
29972861
/* {{{ proto public void ReflectionMethod::__construct(mixed class_or_method [, string name])
29982862
Constructor. Throws an Exception in case the given method does not exist */
29992863
ZEND_METHOD(reflection_method, __construct)
@@ -3750,14 +3614,6 @@ ZEND_METHOD(reflection_class_constant, getDocComment)
37503614
}
37513615
/* }}} */
37523616

3753-
/* {{{ proto public static mixed ReflectionClass::export(mixed argument [, bool return]) throws ReflectionException
3754-
Exports a reflection object. Returns the output if TRUE is specified for return, printing it otherwise. */
3755-
ZEND_METHOD(reflection_class, export)
3756-
{
3757-
_reflection_export(INTERNAL_FUNCTION_PARAM_PASSTHRU, reflection_class_ptr, 1);
3758-
}
3759-
/* }}} */
3760-
37613617
/* {{{ reflection_class_object_ctor */
37623618
static void reflection_class_object_ctor(INTERNAL_FUNCTION_PARAMETERS, int is_object)
37633619
{
@@ -5254,14 +5110,6 @@ ZEND_METHOD(reflection_class, getShortName)
52545110
}
52555111
/* }}} */
52565112

5257-
/* {{{ proto public static mixed ReflectionObject::export(mixed argument [, bool return]) throws ReflectionException
5258-
Exports a reflection object. Returns the output if TRUE is specified for return, printing it otherwise. */
5259-
ZEND_METHOD(reflection_object, export)
5260-
{
5261-
_reflection_export(INTERNAL_FUNCTION_PARAM_PASSTHRU, reflection_object_ptr, 1);
5262-
}
5263-
/* }}} */
5264-
52655113
/* {{{ proto public void ReflectionObject::__construct(mixed argument) throws ReflectionException
52665114
Constructor. Takes an instance as an argument */
52675115
ZEND_METHOD(reflection_object, __construct)
@@ -5270,22 +5118,6 @@ ZEND_METHOD(reflection_object, __construct)
52705118
}
52715119
/* }}} */
52725120

5273-
/* {{{ proto public static mixed ReflectionProperty::export(mixed class, string name [, bool return]) throws ReflectionException
5274-
Exports a reflection object. Returns the output if TRUE is specified for return, printing it otherwise. */
5275-
ZEND_METHOD(reflection_property, export)
5276-
{
5277-
_reflection_export(INTERNAL_FUNCTION_PARAM_PASSTHRU, reflection_property_ptr, 2);
5278-
}
5279-
/* }}} */
5280-
5281-
/* {{{ proto public static mixed ReflectionClassConstant::export(mixed class, string name [, bool return]) throws ReflectionException
5282-
Exports a reflection object. Returns the output if TRUE is specified for return, printing it otherwise. */
5283-
ZEND_METHOD(reflection_class_constant, export)
5284-
{
5285-
_reflection_export(INTERNAL_FUNCTION_PARAM_PASSTHRU, reflection_class_constant_ptr, 2);
5286-
}
5287-
/* }}} */
5288-
52895121
/* {{{ proto public void ReflectionProperty::__construct(mixed class, string name)
52905122
Constructor. Throws an Exception in case the given property does not exist */
52915123
ZEND_METHOD(reflection_property, __construct)
@@ -5782,14 +5614,6 @@ ZEND_METHOD(reflection_property, getDefaultValue)
57825614
}
57835615
/* }}} */
57845616

5785-
/* {{{ proto public static mixed ReflectionExtension::export(string name [, bool return]) throws ReflectionException
5786-
Exports a reflection object. Returns the output if TRUE is specified for return, printing it otherwise. */
5787-
ZEND_METHOD(reflection_extension, export)
5788-
{
5789-
_reflection_export(INTERNAL_FUNCTION_PARAM_PASSTHRU, reflection_extension_ptr, 1);
5790-
}
5791-
/* }}} */
5792-
57935617
/* {{{ proto public void ReflectionExtension::__construct(string name)
57945618
Constructor. Throws an Exception in case the given extension does not exist */
57955619
ZEND_METHOD(reflection_extension, __construct)
@@ -6137,14 +5961,6 @@ ZEND_METHOD(reflection_extension, isTemporary)
61375961
}
61385962
/* }}} */
61395963

6140-
/* {{{ proto public static mixed ReflectionZendExtension::export(string name [, bool return]) throws ReflectionException
6141-
* Exports a reflection object. Returns the output if TRUE is specified for return, printing it otherwise. */
6142-
ZEND_METHOD(reflection_zend_extension, export)
6143-
{
6144-
_reflection_export(INTERNAL_FUNCTION_PARAM_PASSTHRU, reflection_zend_extension_ptr, 1);
6145-
}
6146-
/* }}} */
6147-
61485964
/* {{{ proto public void ReflectionZendExtension::__construct(string name)
61495965
Constructor. Throws an Exception in case the given Zend extension does not exist */
61505966
ZEND_METHOD(reflection_zend_extension, __construct)
@@ -6390,7 +6206,6 @@ static const zend_function_entry reflection_exception_functions[] = {
63906206

63916207
static const zend_function_entry reflection_functions[] = {
63926208
ZEND_ME(reflection, getModifierNames, arginfo_class_Reflection_getModifierNames, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC)
6393-
ZEND_DEP_ME(reflection, export, arginfo_class_Reflection_export, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC)
63946209
PHP_FE_END
63956210
};
63966211

@@ -6432,7 +6247,6 @@ static const zend_function_entry reflection_function_abstract_functions[] = {
64326247
static const zend_function_entry reflection_function_functions[] = {
64336248
ZEND_ME(reflection_function, __construct, arginfo_class_ReflectionFunction___construct, 0)
64346249
ZEND_ME(reflection_function, __toString, arginfo_class_ReflectionFunction___toString, 0)
6435-
ZEND_DEP_ME(reflection_function, export, arginfo_class_ReflectionFunction_export, ZEND_ACC_STATIC|ZEND_ACC_PUBLIC)
64366250
ZEND_ME(reflection_function, isDisabled, arginfo_class_ReflectionFunction_isDisabled, 0)
64376251
ZEND_ME(reflection_function, invoke, arginfo_class_ReflectionFunction_invoke, 0)
64386252
ZEND_ME(reflection_function, invokeArgs, arginfo_class_ReflectionFunction_invokeArgs, 0)
@@ -6452,7 +6266,6 @@ static const zend_function_entry reflection_generator_functions[] = {
64526266
};
64536267

64546268
static const zend_function_entry reflection_method_functions[] = {
6455-
ZEND_DEP_ME(reflection_method, export, arginfo_class_ReflectionMethod_export, ZEND_ACC_STATIC|ZEND_ACC_PUBLIC)
64566269
ZEND_ME(reflection_method, __construct, arginfo_class_ReflectionMethod___construct, 0)
64576270
ZEND_ME(reflection_method, __toString, arginfo_class_ReflectionMethod___toString, 0)
64586271
ZEND_ME(reflection_method, isPublic, arginfo_class_ReflectionMethod_isPublic, 0)
@@ -6475,7 +6288,6 @@ static const zend_function_entry reflection_method_functions[] = {
64756288

64766289
static const zend_function_entry reflection_class_functions[] = {
64776290
ZEND_ME(reflection, __clone, arginfo_class_ReflectionClass___clone, ZEND_ACC_PRIVATE|ZEND_ACC_FINAL)
6478-
ZEND_DEP_ME(reflection_class, export, arginfo_class_ReflectionClass_export, ZEND_ACC_STATIC|ZEND_ACC_PUBLIC)
64796291
ZEND_ME(reflection_class, __construct, arginfo_class_ReflectionClass___construct, 0)
64806292
ZEND_ME(reflection_class, __toString, arginfo_class_ReflectionClass___toString, 0)
64816293
ZEND_ME(reflection_class, getName, arginfo_class_ReflectionClass_getName, 0)
@@ -6532,14 +6344,12 @@ static const zend_function_entry reflection_class_functions[] = {
65326344
};
65336345

65346346
static const zend_function_entry reflection_object_functions[] = {
6535-
ZEND_DEP_ME(reflection_object, export, arginfo_class_ReflectionObject_export, ZEND_ACC_STATIC|ZEND_ACC_PUBLIC)
65366347
ZEND_ME(reflection_object, __construct, arginfo_class_ReflectionObject___construct, 0)
65376348
PHP_FE_END
65386349
};
65396350

65406351
static const zend_function_entry reflection_property_functions[] = {
65416352
ZEND_ME(reflection, __clone, arginfo_class_ReflectionProperty___clone, ZEND_ACC_PRIVATE|ZEND_ACC_FINAL)
6542-
ZEND_DEP_ME(reflection_property, export, arginfo_class_ReflectionProperty_export, ZEND_ACC_STATIC|ZEND_ACC_PUBLIC)
65436353
ZEND_ME(reflection_property, __construct, arginfo_class_ReflectionProperty___construct, 0)
65446354
ZEND_ME(reflection_property, __toString, arginfo_class_ReflectionProperty___toString, 0)
65456355
ZEND_ME(reflection_property, getName, arginfo_class_ReflectionProperty_getName, 0)
@@ -6564,7 +6374,6 @@ static const zend_function_entry reflection_property_functions[] = {
65646374

65656375
static const zend_function_entry reflection_class_constant_functions[] = {
65666376
ZEND_ME(reflection, __clone, arginfo_class_ReflectionClassConstant___clone, ZEND_ACC_PRIVATE|ZEND_ACC_FINAL)
6567-
ZEND_DEP_ME(reflection_class_constant, export, arginfo_class_ReflectionClassConstant_export, ZEND_ACC_STATIC|ZEND_ACC_PUBLIC)
65686377
ZEND_ME(reflection_class_constant, __construct, arginfo_class_ReflectionClassConstant___construct, 0)
65696378
ZEND_ME(reflection_class_constant, __toString, arginfo_class_ReflectionClassConstant___toString, 0)
65706379
ZEND_ME(reflection_class_constant, getName, arginfo_class_ReflectionClassConstant_getName, 0)
@@ -6580,7 +6389,6 @@ static const zend_function_entry reflection_class_constant_functions[] = {
65806389

65816390
static const zend_function_entry reflection_parameter_functions[] = {
65826391
ZEND_ME(reflection, __clone, arginfo_class_ReflectionParameter___clone, ZEND_ACC_PRIVATE|ZEND_ACC_FINAL)
6583-
ZEND_DEP_ME(reflection_parameter, export, arginfo_class_ReflectionParameter_export, ZEND_ACC_STATIC|ZEND_ACC_PUBLIC)
65846392
ZEND_ME(reflection_parameter, __construct, arginfo_class_ReflectionParameter___construct, 0)
65856393
ZEND_ME(reflection_parameter, __toString, arginfo_class_ReflectionParameter___toString, 0)
65866394
ZEND_ME(reflection_parameter, getName, arginfo_class_ReflectionParameter_getName, 0)
@@ -6624,7 +6432,6 @@ static const zend_function_entry reflection_union_type_functions[] = {
66246432

66256433
static const zend_function_entry reflection_extension_functions[] = {
66266434
ZEND_ME(reflection, __clone, arginfo_class_ReflectionExtension___clone, ZEND_ACC_PRIVATE|ZEND_ACC_FINAL)
6627-
ZEND_DEP_ME(reflection_extension, export, arginfo_class_ReflectionExtension_export, ZEND_ACC_STATIC|ZEND_ACC_PUBLIC)
66286435
ZEND_ME(reflection_extension, __construct, arginfo_class_ReflectionExtension___construct, 0)
66296436
ZEND_ME(reflection_extension, __toString, arginfo_class_ReflectionExtension___toString, 0)
66306437
ZEND_ME(reflection_extension, getName, arginfo_class_ReflectionExtension_getName, 0)
@@ -6643,7 +6450,6 @@ static const zend_function_entry reflection_extension_functions[] = {
66436450

66446451
static const zend_function_entry reflection_zend_extension_functions[] = {
66456452
ZEND_ME(reflection, __clone, arginfo_class_ReflectionZendExtension___clone, ZEND_ACC_PRIVATE|ZEND_ACC_FINAL)
6646-
ZEND_DEP_ME(reflection_zend_extension, export, arginfo_class_ReflectionZendExtension_export, ZEND_ACC_STATIC|ZEND_ACC_PUBLIC)
66476453
ZEND_ME(reflection_zend_extension, __construct, arginfo_class_ReflectionZendExtension___construct, 0)
66486454
ZEND_ME(reflection_zend_extension, __toString, arginfo_class_ReflectionZendExtension___toString, 0)
66496455
ZEND_ME(reflection_zend_extension, getName, arginfo_class_ReflectionZendExtension_getName, 0)

0 commit comments

Comments
 (0)