Re: Type hinting
| From: | Tjerk Anne Meesters | Date: | Wed, 02 Jun 2010 04:06:33 +0000 |
| Subject: | Re: Type hinting | ||
| References: | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-48602@lists.php.net to get a copy of this message | ||
On Wed, Jun 2, 2010 at 7:41 AM, Chad Fulton <chadfulton@gmail.com> wrote:
> Hi!
>
>> Pretty much everywhere. Suppose you have form with, say, 2 fields and first
>> field does not validate. Maybe you want to check the second field too and
>> give the user both errors if they are both wrong?
>>
>> In general, looking at strict typing as user input validation mechanism is a
>> very bad idea. There are specialized use input validation
>> functions/classes/frameworks, and one should use them.
>
> Right, that was my point. I can't think of any good reason to use
> exceptions rather than global errors (E_NOTICE or E_STRICT or
> similar), but some people seem to want exceptions.
>
> I was asking them if they had use valid cases (e.g. *not* data
> validation or similar which is undoubtably foolish) that would merit
> using exceptions rather than the global error handling.
Regardless of whether it's used for validation (which I agree is a bad
idea), type errors may still occur elsewhere in the code; being able
to handle those errors using exceptions has the advantage of keeping
the context; a custom error handler lacks this and wouldn't be able to
distinguish between errors, let alone be able to show the end-user any
decent feedback.
>
> --
> PHP Internals - PHP Runtime Development Mailing List
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
--
--
Tjerk