Skip to content

Commit 1a90173

Browse files
laruencesmalyshev
authored andcommitted
Revert "Implemented FR #61602 Allow access to name of constant used as default value"
This reverts commit 054f3e3. See: http://news.php.net/php.cvs/69137 and the author confirmed. Will commit later after the author fixed this then make a new PR. Conflicts: ext/reflection/php_reflection.c
1 parent b233c19 commit 1a90173

4 files changed

+8
-192
lines changed

ext/reflection/php_reflection.c

Lines changed: 8 additions & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -1457,49 +1457,6 @@ static void _reflection_export(INTERNAL_FUNCTION_PARAMETERS, zend_class_entry *c
14571457
}
14581458
/* }}} */
14591459

1460-
/* {{{ _reflection_param_get_default_param */
1461-
static parameter_reference *_reflection_param_get_default_param(INTERNAL_FUNCTION_PARAMETERS)
1462-
{
1463-
reflection_object *intern;
1464-
parameter_reference *param;
1465-
1466-
GET_REFLECTION_OBJECT_PTR(param);
1467-
1468-
if (param->fptr->type != ZEND_USER_FUNCTION)
1469-
{
1470-
zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, "Cannot determine default value for internal functions");
1471-
return NULL;
1472-
}
1473-
1474-
if (param->offset < param->required) {
1475-
zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, "Parameter is not optional");
1476-
return NULL;
1477-
}
1478-
1479-
return param;
1480-
}
1481-
/* }}} */
1482-
1483-
/* {{{ _reflection_param_get_default_precv */
1484-
static zend_op *_reflection_param_get_default_precv(INTERNAL_FUNCTION_PARAMETERS, parameter_reference *param)
1485-
{
1486-
zend_op *precv;
1487-
1488-
param = param ? param : _reflection_param_get_default_param(INTERNAL_FUNCTION_PARAM_PASSTHRU);
1489-
if (!param) {
1490-
return NULL;
1491-
}
1492-
1493-
precv = _get_recv_op((zend_op_array*)param->fptr, param->offset);
1494-
if (!precv || precv->opcode != ZEND_RECV_INIT || precv->op2_type == IS_UNUSED) {
1495-
zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, "Internal error");
1496-
return NULL;
1497-
}
1498-
1499-
return precv;
1500-
}
1501-
/* }}} */
1502-
15031460
/* {{{ Preventing __clone from being called */
15041461
ZEND_METHOD(reflection, __clone)
15051462
{
@@ -2578,22 +2535,26 @@ ZEND_METHOD(reflection_parameter, isDefaultValueAvailable)
25782535
Returns the default value of this parameter or throws an exception */
25792536
ZEND_METHOD(reflection_parameter, getDefaultValue)
25802537
{
2581-
parameter_reference *param = _reflection_param_get_default_param(INTERNAL_FUNCTION_PARAM_PASSTHRU);
2582-
zend_op *precv = _reflection_param_get_default_precv(INTERNAL_FUNCTION_PARAM_PASSTHRU, param);
2538+
reflection_object *intern;
2539+
parameter_reference *param;
2540+
zend_op *precv;
25832541

25842542
if (zend_parse_parameters_none() == FAILURE) {
25852543
return;
25862544
}
2545+
GET_REFLECTION_OBJECT_PTR(param);
25872546

2588-
if (!(param && precv)) {
2547+
if (param->fptr->type != ZEND_USER_FUNCTION)
2548+
{
2549+
zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, "Cannot determine default value for internal functions");
25892550
return;
25902551
}
25912552
if (param->offset < param->required) {
25922553
zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, "Parameter is not optional");
25932554
return;
25942555
}
25952556
precv = _get_recv_op((zend_op_array*)param->fptr, param->offset);
2596-
if (!precv || precv->opcode != ZEND_RECV_INIT || precv->op2.op_type == IS_UNUSED) {
2557+
if (!precv || precv->opcode != ZEND_RECV_INIT || precv->op2_type == IS_UNUSED) {
25972558
zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, "Internal error");
25982559
return;
25992560
}
@@ -2607,42 +2568,6 @@ ZEND_METHOD(reflection_parameter, getDefaultValue)
26072568
}
26082569
/* }}} */
26092570

2610-
/* {{{ proto public bool ReflectionParameter::isDefaultValueConstant()
2611-
Returns whether the default value of this parameter is constant */
2612-
ZEND_METHOD(reflection_parameter, isDefaultValueConstant)
2613-
{
2614-
zend_op *precv = _reflection_param_get_default_precv(INTERNAL_FUNCTION_PARAM_PASSTHRU, NULL);
2615-
2616-
if (zend_parse_parameters_none() == FAILURE) {
2617-
return;
2618-
}
2619-
2620-
if (precv && (Z_TYPE_P(precv->op2.zv) & IS_CONSTANT_TYPE_MASK) == IS_CONSTANT) {
2621-
RETURN_TRUE;
2622-
}
2623-
2624-
RETURN_FALSE;
2625-
}
2626-
/* }}} */
2627-
2628-
/* {{{ proto public mixed ReflectionParameter::getDefaultValueConstantName()
2629-
Returns the default value's constant name if default value is constant or false */
2630-
ZEND_METHOD(reflection_parameter, getDefaultValueConstantName)
2631-
{
2632-
zend_op *precv = _reflection_param_get_default_precv(INTERNAL_FUNCTION_PARAM_PASSTHRU, NULL);
2633-
2634-
if (zend_parse_parameters_none() == FAILURE) {
2635-
return;
2636-
}
2637-
2638-
if (precv && (Z_TYPE_P(precv->op2.zv) & IS_CONSTANT_TYPE_MASK) == IS_CONSTANT) {
2639-
RETURN_STRING(Z_STRVAL_P(precv->op2.zv), 1);
2640-
}
2641-
2642-
RETURN_FALSE;
2643-
}
2644-
/* }}} */
2645-
26462571
/* {{{ proto public static mixed ReflectionMethod::export(mixed class, string name [, bool return]) throws ReflectionException
26472572
Exports a reflection object. Returns the output if TRUE is specified for return, printing it otherwise. */
26482573
ZEND_METHOD(reflection_method, export)
@@ -5978,8 +5903,6 @@ static const zend_function_entry reflection_parameter_functions[] = {
59785903
ZEND_ME(reflection_parameter, isOptional, arginfo_reflection__void, 0)
59795904
ZEND_ME(reflection_parameter, isDefaultValueAvailable, arginfo_reflection__void, 0)
59805905
ZEND_ME(reflection_parameter, getDefaultValue, arginfo_reflection__void, 0)
5981-
ZEND_ME(reflection_parameter, isDefaultValueConstant, arginfo_reflection__void, 0)
5982-
ZEND_ME(reflection_parameter, getDefaultValueConstantName, arginfo_reflection__void, 0)
59835906
PHP_FE_END
59845907
};
59855908

ext/reflection/tests/ReflectionParameter_DefaultValueConstant_basic1.phpt

Lines changed: 0 additions & 52 deletions
This file was deleted.

ext/reflection/tests/ReflectionParameter_DefaultValueConstant_basic2.phpt

Lines changed: 0 additions & 30 deletions
This file was deleted.

ext/reflection/tests/ReflectionParameter_DefaultValueConstant_error.phpt

Lines changed: 0 additions & 25 deletions
This file was deleted.

0 commit comments

Comments
 (0)