RE: [PHP] How to type arguments
| From: | ceo at l-i-e dot com | Date: | Wed, 03 Dec 2008 15:11:08 +0000 |
| Subject: | RE: [PHP] How to type arguments | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-284056@lists.php.net to get a copy of this message | ||
I'm surprised nobody mentioned:
http://php.net/assert
in this thread yet.
Perhaps I missed it?
You should really consider doing this:
1) At the outer API layer, do a typecast (possibly with preg_match first) to convert the input data
to acceptable form.
2) For inner API layer[s], sprinkle "assert" calls as needed to make sure during
dev/testing that the outer layer is doing it right.
In PROD, the assert can turn into a no-op, with no performance penalty, as I understand it.
Disclosure:
I've never worked on a project organized enough to actually do this properly. Sigh.
:-)