Re: [RFC] Scalar Type Hinting With Casts (re-opening)
| From: | Andrea Faulds | Date: | Wed, 16 Jul 2014 23:37:24 +0000 |
| Subject: | Re: [RFC] Scalar Type Hinting With Casts (re-opening) | ||
| References: | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-75617@lists.php.net to get a copy of this message | ||
On 17 Jul 2014, at 00:23, Stas Malyshev <smalyshev@sugarcrm.com> wrote:
> I think this is not correct. It can be OK in one context and error in
> another. I.e., if you say "let's ask users how many gizmos they want"
> and the user gives "1 " (note the space) and we tell them "we don't know
> what this even means, there's an extra character there" - doing this
> would just annoy the user. Silently converting it to 1 would do the
> right thing.
>
> If you say making any distinction between "1" and "1 " is useless for
> you - well, I can accept that. I can see use cases where it makes sense
> to make distinction but they are a minority. I think there's a level
> between E_RECOVERABLE_ERROR and silence where it's not "I can't make any
> sense out of this garbage" but also not "it's clean data". But I can
> also live without this level, if that is what the majority comes to. In
> that case, I'd rather have "1 " converted to 1 silently.
There are really only two levels of error IMO, those that are log file messages (silenced or no),
and those that actually stop the script unless handled. I worry about making E_CAST the former but
allowing people to make it the latter, because then people would and suddenly code relying on it
being the former would make your app stop working.
--
Andrea Faulds
http://ajf.me/