summaryrefslogtreecommitdiff
path: root/ext/reflection/php_reflection.c
diff options
context:
space:
mode:
authorNikita Popov <nikic@php.net>2013-09-26 18:39:17 +0200
committerNikita Popov <nikic@php.net>2013-09-26 18:39:17 +0200
commit0d7a6388663b76ebed6585ac92dfca5ef65fa7af (patch)
tree1317a8a47c0e4bd1193c8fbf705d91ae75140f78 /ext/reflection/php_reflection.c
parent6daa04a4f606f8121d9f1ea6cd90c1c8a684500e (diff)
downloadphp-git-0d7a6388663b76ebed6585ac92dfca5ef65fa7af.tar.gz
Implement variadic function syntax
As per RFC: https://wiki.php.net/rfc/variadics
Diffstat (limited to 'ext/reflection/php_reflection.c')
-rw-r--r--ext/reflection/php_reflection.c33
1 files changed, 31 insertions, 2 deletions
diff --git a/ext/reflection/php_reflection.c b/ext/reflection/php_reflection.c
index b1f7484f24..cc148b39c5 100644
--- a/ext/reflection/php_reflection.c
+++ b/ext/reflection/php_reflection.c
@@ -681,8 +681,8 @@ static zend_op* _get_recv_op(zend_op_array *op_array, zend_uint offset)
++offset;
while (op < end) {
- if ((op->opcode == ZEND_RECV || op->opcode == ZEND_RECV_INIT)
- && op->op1.num == (long)offset)
+ if ((op->opcode == ZEND_RECV || op->opcode == ZEND_RECV_INIT
+ || op->opcode == ZEND_RECV_VARIADIC) && op->op1.num == (long)offset)
{
return op;
}
@@ -715,6 +715,9 @@ static void _parameter_string(string *str, zend_function *fptr, struct _zend_arg
if (arg_info->pass_by_reference) {
string_write(str, "&", sizeof("&")-1);
}
+ if (arg_info->is_variadic) {
+ string_write(str, "...", sizeof("...")-1);
+ }
if (arg_info->name) {
string_printf(str, "$%s", arg_info->name);
} else {
@@ -2652,6 +2655,22 @@ ZEND_METHOD(reflection_parameter, getDefaultValueConstantName)
}
/* }}} */
+/* {{{ proto public bool ReflectionParameter::isVariadic()
+ Returns whether this parameter is a variadic parameter */
+ZEND_METHOD(reflection_parameter, isVariadic)
+{
+ reflection_object *intern;
+ parameter_reference *param;
+
+ if (zend_parse_parameters_none() == FAILURE) {
+ return;
+ }
+ GET_REFLECTION_OBJECT_PTR(param);
+
+ RETVAL_BOOL(param->arg_info->is_variadic);
+}
+/* }}} */
+
/* {{{ proto public static mixed ReflectionMethod::export(mixed class, string name [, bool return]) throws ReflectionException
Exports a reflection object. Returns the output if TRUE is specified for return, printing it otherwise. */
ZEND_METHOD(reflection_method, export)
@@ -3095,6 +3114,14 @@ ZEND_METHOD(reflection_function, isGenerator)
}
/* }}} */
+/* {{{ proto public bool ReflectionFunction::isVariadic()
+ Returns whether this function is variadic */
+ZEND_METHOD(reflection_function, isVariadic)
+{
+ _function_check_flag(INTERNAL_FUNCTION_PARAM_PASSTHRU, ZEND_ACC_VARIADIC);
+}
+/* }}} */
+
/* {{{ proto public bool ReflectionFunction::inNamespace()
Returns whether this function is defined in namespace */
ZEND_METHOD(reflection_function, inNamespace)
@@ -5720,6 +5747,7 @@ static const zend_function_entry reflection_function_abstract_functions[] = {
ZEND_ME(reflection_function, isInternal, arginfo_reflection__void, 0)
ZEND_ME(reflection_function, isUserDefined, arginfo_reflection__void, 0)
ZEND_ME(reflection_function, isGenerator, arginfo_reflection__void, 0)
+ ZEND_ME(reflection_function, isVariadic, arginfo_reflection__void, 0)
ZEND_ME(reflection_function, getClosureThis, arginfo_reflection__void, 0)
ZEND_ME(reflection_function, getClosureScopeClass, arginfo_reflection__void, 0)
ZEND_ME(reflection_function, getDocComment, arginfo_reflection__void, 0)
@@ -6022,6 +6050,7 @@ static const zend_function_entry reflection_parameter_functions[] = {
ZEND_ME(reflection_parameter, getDefaultValue, arginfo_reflection__void, 0)
ZEND_ME(reflection_parameter, isDefaultValueConstant, arginfo_reflection__void, 0)
ZEND_ME(reflection_parameter, getDefaultValueConstantName, arginfo_reflection__void, 0)
+ ZEND_ME(reflection_parameter, isVariadic, arginfo_reflection__void, 0)
PHP_FE_END
};