summaryrefslogtreecommitdiff
path: root/ext/reflection/php_reflection.c
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 /ext/reflection/php_reflection.c
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 'ext/reflection/php_reflection.c')
0 files changed, 0 insertions, 0 deletions