Validate complex types
| From: | François Gannaz | Date: | Fri, 23 Mar 2012 16:26:08 +0000 |
| Subject: | Validate complex types | ||
| Groups: | php.internals | ||
| Request: | Send a blank email to internals+get-59141@lists.php.net to get a copy of this message | ||
Hello
I'm wondering if there is a recommended way to validate a multi-type parameter
in an internal function. If a parameter is expected to be "long or string" or
to be "integer or null", a simple call to
zend_parse_parameters() won't
validate it.
I read some extensions' code, and it seems that the preferred method is to call
zend_parse_parameters(_ex) several times until one validation succeeds or all
fail. I really don't like this solution. Maybe the performance penalty of
parsing twice the arguments is negligible, but I don't even like the idea of
this code. Isn't there a better solution? Or did I miss a good reason for this?
I wanted to use zend_parse_arg() to validate a single parameter if the
first call to zend_parse_parameters_ex() wasn't successful. But this function
is never used outside of "Zend/zend_API.c". Is it meant for public use? Are
there any drawbacks in calling it?
Regards
--
François Gannaz