Le Wed Nov 19 2014 at 10:57:39 PM, Levi Morrison <le...@php.net> a écrit :
>
>   - PHP suffers a lot from function bloat and this RFC provides
> multiple functions that do the same thing but differ only in how they
> handle errors. A simple validation of "can this be safely cast to an
> integer without dataloss?" avoid the issue entirely and would be fewer
> functions.
>

My "no" is mostly for the reason above, mentioned by Levi and also because
of the use of Exception (previously mentioned by Derick as well).

To improve this RFC, I would:
- use errors/warnings instead of exceptions (unless there is a more global
approach on this aspect for PHP 7).
- improve ext/filter to have stricter validation/sanitizing mechanism if
this is missing.

I would personally appreciate a syntax closer to the current casting
mechanism, e.g.:

    $int = (=int) "42"; // result: (int) 42
    $string = (=string) 42; // result: (string) "42"
    $int = (=int) "foobar"; // result: E_ERROR: Can not cast (string)
"foobar" strictly to an int

    $int = (~int) "42"; // result: (int) 42
    $int = (~int) "foobar"; // result: E_WARNING: Can not cast (string)
"foobar" strictly to an int

Note that I haven't investigate any possible syntax conflict.

My 2 €cents.

Regards,
Patrick

Reply via email to