summaryrefslogtreecommitdiff
path: root/Zend/zend_API.h
diff options
context:
space:
mode:
authorGustavo André dos Santos Lopes <cataphract@php.net>2012-07-18 22:05:42 +0200
committerGustavo André dos Santos Lopes <cataphract@php.net>2012-07-18 23:30:03 +0200
commit13f1d53b689480776d70e256ebd3fc44fd2e253d (patch)
treeed1d1e6d4d41d3325416f696431ed0780abab949 /Zend/zend_API.h
parent980dc7111bc1d1e759c5b6044f6e7d203915d81f (diff)
downloadphp-git-13f1d53b689480776d70e256ebd3fc44fd2e253d.tar.gz
Expose zend_parse_arg() as zend_parse_parameter()
Sometimes, one wants to accept several types for a given parameter. zpp has special functionality for detecting the NULL type, since the NULL type is frequently used to skip parameters. However, supporting several types is otherwise very tedious. There are many cases where this situation arises -- for instance one may want to accept an arbitrary number of integer and expect them in an array, but allow a bare integer too; one may want to accept something that will be used as an array key (which can be either and int or a string); one may want to accept integer and double numbers. A search for IS_LONG reveals many situations where this need arises. The usual solution is to fetch the argument with 'z'/'Z', check its type, and then convert the argument, e.g. with convert_to_long_ex(). As explain in the last commit, this has different behavior and generates inconsistency. Another -- even more flawed strategy --, is to try zpp with a specific format, forcing it quiet, and if it fails retrying with another form. But because zpp changes the arguments directly in the stack (for instance, using "l" converts the zval in the stack to IS_LONG), the arguments may look different after the first zpp, leaving subtle bugs. This commit also allows more complex scenarios, for instance where the expected type of one parameter depends on other parameters.
Diffstat (limited to 'Zend/zend_API.h')
-rw-r--r--Zend/zend_API.h2
1 files changed, 2 insertions, 0 deletions
diff --git a/Zend/zend_API.h b/Zend/zend_API.h
index f54db7f2e8..f65fb172c5 100644
--- a/Zend/zend_API.h
+++ b/Zend/zend_API.h
@@ -253,6 +253,8 @@ ZEND_API char *zend_zval_type_name(const zval *arg);
ZEND_API int zend_parse_method_parameters(int num_args TSRMLS_DC, zval *this_ptr, const char *type_spec, ...);
ZEND_API int zend_parse_method_parameters_ex(int flags, int num_args TSRMLS_DC, zval *this_ptr, const char *type_spec, ...);
+int zend_parse_parameter(int flags, int arg_num TSRMLS_DC, zval **arg, const char *spec, ...);
+
/* End of parameter parsing API -- andrei */
ZEND_API int zend_register_functions(zend_class_entry *scope, const zend_function_entry *functions, HashTable *function_table, int type TSRMLS_DC);